Merge branch 'develop' into trunk

This commit is contained in:
Vincent BRIDIER 2024-10-23 18:44:47 +02:00
commit 2779617c1a
No known key found for this signature in database
GPG key ID: 8571BFA20420D512
15 changed files with 603 additions and 66 deletions

View file

@ -35,7 +35,7 @@ class CustomerController extends Controller
$questions = Customer::cacheCrm(
$customer->hashcode,
'questions',
fn () => collect(Question::all())->filter(function ($question) {
fn() => collect(Question::all())->filter(function ($question) {
return $question->id === intval(config('crm.question'));
})
);
@ -67,7 +67,9 @@ class CustomerController extends Controller
if (
$this->updateCrmCustomerInfo($customer, collect($request->validated())->except([
'password', 'ok_cgv', 'ok_cgu'
'password',
'ok_cgv',
'ok_cgu'
])->toArray())
) {
if ($customer->saveOrFail()) {
@ -165,7 +167,7 @@ class CustomerController extends Controller
public function indexRecipes(): \Illuminate\Contracts\View\View
{
$models = Recipe::query()->with('products', 'consumptionMoment')
->where('published', true)->take(15)->paginate(9);
->where('published', true)->take(15)->paginate(9);
return view('club.pages.customers.favorites.recipes', compact('models'));
}
}

View file

@ -15,8 +15,8 @@ class HomeController extends Controller
*/
public function index(): \Illuminate\Contracts\View\View
{
$newsClubModels = NewsClub::query()->where('published', true)->orderBy('publish_at', 'asc')->take(3)->get();
$discountModels = Discount::query()->get();
$newsClubModels = NewsClub::getPublishedOrderedByPublishAt();
$discountModels = Discount::getCachedDiscounts();
$discountsTotal = $discountModels->sum('value');
return (auth('club')->check())
? view('club.pages.home.homepage', compact('newsClubModels', 'discountModels', 'discountsTotal'))

View file

@ -39,12 +39,14 @@ class HomeController extends Controller
$mainSlideModels = MainSlide::getPublishedOrderedWithApproaches();
$demarcheSlideModels = DemarcheSlide::getPublishedOrdered();
$rangeModels = Range::getPublishedOrderedBySlug();
$productViews = Product::getProductsViewsByRange();
$productViews = Cache::remember('HomeProductsViews', 86400, function () {
return Product::getProductsViewsByRange();
});
$hotNewsSettings = GeneralSetting::getCachedGeneralSetting(SettingsType::hotNews);
$newsModels = News::getPublishedWithNewsCategory();
$recipeModels = Recipe::get9PublishedWithProducts();
$videoModels = Video::get9PublishedHomeVideosOrderedWithProducts();
$discountsTotal = Discount::query()->get()->sum('value');
$discountsTotal = Discount::getCachedDiscounts()->sum('value');
return view('fo.pages.home', compact(
'staticPageModel',
'mainSlideModels',

View file

@ -141,8 +141,8 @@ class Customer extends Authenticatable implements MustVerifyEmail
*/
public function conversations(): array
{
$dateSort = fn (Message $a, Message $b) => $a->created_at->timestamp > $b->created_at->timestamp;
$messageFilter = fn (Collection $item) => $item->all();
$dateSort = fn(Message $a, Message $b) => $a->created_at->timestamp > $b->created_at->timestamp;
$messageFilter = fn(Collection $item) => $item->all();
$messageWith = ['fromCustomer', 'toCustomer'];
/**
* Hack workaround https://github.com/livewire/livewire/issues/1054
@ -304,7 +304,7 @@ class Customer extends Authenticatable implements MustVerifyEmail
public function apiData(): \Illuminate\Database\Eloquent\Casts\Attribute
{
return Attribute::make(
get: fn (): CrmCustomer => self::cacheCrm($this->hashcode, "apiData", function () {
get: fn(): CrmCustomer => self::cacheCrm($this->hashcode, "apiData", function () {
/** @var \LDC\LDCCRM\CrmApiV4 */
$crm = app('crmAPI');
$crmCustomer = $crm->getCustomer($this->hashcode);
@ -334,10 +334,12 @@ class Customer extends Authenticatable implements MustVerifyEmail
if (!$crmCustomer) {
throw new CrmException('CRM get Customer returned null');
}
$data['postcode'] = Arr::get($data, 'postal_code');
unset(
$data["username"],
$data["question_id"],
$data["answers"]
$data["answers"],
$data["postal_code"]
);
$crmCustomer->fill($data);
$result = $crmCustomer->save();

View file

@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Cache;
/**
* @property string $name Discount name.
@ -73,6 +74,7 @@ class Discount extends Model
$discountModel = new self();
self::fillModel($discountModel, $coupon);
}
self::getCachedDiscounts();
}
/**
@ -192,4 +194,16 @@ class Discount extends Model
]))->all();
return $res;
}
/**
* Get cached discounts or remember it for 24h.
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public static function getCachedDiscounts(): \Illuminate\Database\Eloquent\Collection
{
return Cache::remember('publishedDiscounts', 86400, function () {
return self::query()->get();
});
}
}

View file

@ -8,6 +8,7 @@ use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Cache;
use App\Lib\Helpers\ToolboxHelper;
/**
@ -69,15 +70,20 @@ class NewsClub extends Model
self::assertTitleIsUnique($newsClub->title);
self::manageFields($newsClub);
});
static::created(function () {
self::resetCache();
});
static::updating(function (self $newsClub) {
self::assertTitleIsUnique($newsClub->title, $newsClub->getKey());
self::manageFields($newsClub);
});
static::updated(function (self $model) {
FileStorageHelper::removeOldFile($model, 'picture');
self::resetCache();
});
static::deleted(function (self $model) {
FileStorageHelper::removeFile($model, 'picture');
self::resetCache();
});
}
@ -110,6 +116,29 @@ class NewsClub extends Model
ToolboxHelper::assertFieldIsUnique($table, 'slug', Str::slug($title), $id);
}
/**
* Reset all cache elements related to this model.
*
* @return void
*/
private static function resetCache(): void
{
Cache::forget('publishedNewsClubOrderedByPublishAt');
self::getPublishedOrderedByPublishAt();
}
/**
* Get all published news with categories relations.
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public static function getPublishedOrderedByPublishAt(): \Illuminate\Database\Eloquent\Collection
{
return Cache::rememberForever('publishedNewsClubOrderedByPublishAt', function () {
return self::query()->where('published', true)->orderBy('publish_at', 'asc')->take(3)->get();
});
}
// * RELATIONSHIPS
/**

View file

@ -63,6 +63,19 @@ class AppServiceProvider extends ServiceProvider
});
}
/**
* Register any application services.
*
* @return void
*/
public function register(): void
{
if ($this->app->environment('local')) {
$this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
$this->app->register(TelescopeServiceProvider::class);
}
}
/**
* Set formatters and payment currency.
*

View file

@ -0,0 +1,64 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Gate;
use Laravel\Telescope\IncomingEntry;
use Laravel\Telescope\Telescope;
use Laravel\Telescope\TelescopeApplicationServiceProvider;
class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
// Telescope::night();
$this->hideSensitiveRequestDetails();
$isLocal = $this->app->environment('local');
Telescope::filter(function (IncomingEntry $entry) use ($isLocal) {
return $isLocal ||
$entry->isReportableException() ||
$entry->isFailedRequest() ||
$entry->isFailedJob() ||
$entry->isScheduledTask() ||
$entry->hasMonitoredTag();
});
}
/**
* Prevent sensitive request details from being logged by Telescope.
*/
protected function hideSensitiveRequestDetails(): void
{
if ($this->app->environment('local')) {
return;
}
Telescope::hideRequestParameters(['_token']);
Telescope::hideRequestHeaders([
'cookie',
'x-csrf-token',
'x-xsrf-token',
]);
}
/**
* Register the Telescope gate.
*
* This gate determines who can access Telescope in non-local environments.
*/
protected function gate(): void
{
Gate::define('viewTelescope', function ($user) {
return in_array($user->email, [
//
]);
});
}
}

View file

@ -96,11 +96,20 @@ class ViewServiceProvider extends ServiceProvider
});
// * Inject some data for the bo menu.
$customerModelsCount = Cache::remember('customerModelsCount', 86400, function () {
return Customer::query()->count();
});
$firstMeat = Cache::remember('firstMeat', 86400, function () {
return Meat::query()->first();
});
$firstRange = Cache::remember('firstRange', 86400, function () {
return Range::query()->first();
});
// @phpcs:disable Generic.Files.LineLength.TooLong
collect([
['name' => 'customerModelsCount', 'value' => Customer::query()->count()],
['name' => 'firstMeat', 'value' => Meat::query()->first()],
['name' => 'firstRange', 'value' => Range::query()->first()],
['name' => 'customerModelsCount', 'value' => $customerModelsCount],
['name' => 'firstMeat', 'value' => $firstMeat],
['name' => 'firstRange', 'value' => $firstRange],
['name' => 'mainMenuRangeModels', 'value' => Range::getPublishedOrdered()],
['name' => 'mainMenuMeatModels', 'value' => Meat::getPublishedOrdered()],
['name' => 'homeStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::home)],

View file

@ -44,6 +44,7 @@
"laravel-lang/common": "^4.0",
"laravel/pint": "^1.0",
"laravel/sail": "^1.18",
"laravel/telescope": "^5.2",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^8.1",
"phpunit/phpunit": "^10.0",
@ -87,7 +88,9 @@
},
"extra": {
"laravel": {
"dont-discover": []
"dont-discover": [
"laravel/telescope"
]
}
},
"config": {

82
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "330991754ddc1dffc7b61172bcbc72ea",
"content-hash": "e2e7d8fb63efe18287324559a12425ea",
"packages": [
{
"name": "24slides/laravel-saml2",
@ -2511,19 +2511,20 @@
},
{
"name": "ldc/ldccrmv4client",
"version": "4.0.2",
"version": "4.0.8",
"source": {
"type": "git",
"url": "git@lab.s-web.fr:ldc-web/projets/crm-client.git",
"reference": "01c616ef3316f257646252dc971852dacdc20bcd"
"reference": "588e74e951f376096a7bdea0c74e41200496a47e"
},
"dist": {
"type": "zip",
"url": "https://lab.s-web.fr/api/v4/projects/26/packages/composer/archives/ldc/ldccrmv4client.zip?sha=01c616ef3316f257646252dc971852dacdc20bcd",
"reference": "01c616ef3316f257646252dc971852dacdc20bcd",
"url": "https://lab.s-web.fr/api/v4/projects/26/packages/composer/archives/ldc/ldccrmv4client.zip?sha=588e74e951f376096a7bdea0c74e41200496a47e",
"reference": "588e74e951f376096a7bdea0c74e41200496a47e",
"shasum": ""
},
"require": {
"doctrine/inflector": "^2.0",
"ext-curl": "*",
"guzzlehttp/guzzle": "^7.4",
"php": "^8.2",
@ -9901,6 +9902,75 @@
},
"time": "2024-09-27T14:58:09+00:00"
},
{
"name": "laravel/telescope",
"version": "v5.2.3",
"source": {
"type": "git",
"url": "https://github.com/laravel/telescope.git",
"reference": "a7e9e1332361a31de6eb94cf1d356500c3a89301"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/telescope/zipball/a7e9e1332361a31de6eb94cf1d356500c3a89301",
"reference": "a7e9e1332361a31de6eb94cf1d356500c3a89301",
"shasum": ""
},
"require": {
"ext-json": "*",
"laravel/framework": "^8.37|^9.0|^10.0|^11.0",
"php": "^8.0",
"symfony/console": "^5.3|^6.0|^7.0",
"symfony/var-dumper": "^5.0|^6.0|^7.0"
},
"require-dev": {
"ext-gd": "*",
"guzzlehttp/guzzle": "^6.0|^7.0",
"laravel/octane": "^1.4|^2.0|dev-develop",
"orchestra/testbench": "^6.40|^7.37|^8.17|^9.0",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9.0|^10.5"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Laravel\\Telescope\\TelescopeServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Laravel\\Telescope\\": "src/",
"Laravel\\Telescope\\Database\\Factories\\": "database/factories/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
},
{
"name": "Mohamed Said",
"email": "mohamed@laravel.com"
}
],
"description": "An elegant debug assistant for the Laravel framework.",
"keywords": [
"debugging",
"laravel",
"monitoring"
],
"support": {
"issues": "https://github.com/laravel/telescope/issues",
"source": "https://github.com/laravel/telescope/tree/v5.2.3"
},
"time": "2024-10-13T15:11:07+00:00"
},
{
"name": "mockery/mockery",
"version": "1.6.12",
@ -12523,5 +12593,5 @@
"ext-bcmath": "*"
},
"platform-dev": [],
"plugin-api-version": "2.3.0"
"plugin-api-version": "2.6.0"
}

205
config/telescope.php Normal file
View file

@ -0,0 +1,205 @@
<?php
use Laravel\Telescope\Http\Middleware\Authorize;
use Laravel\Telescope\Watchers;
return [
/*
|--------------------------------------------------------------------------
| Telescope Master Switch
|--------------------------------------------------------------------------
|
| This option may be used to disable all Telescope watchers regardless
| of their individual configuration, which simply provides a single
| and convenient way to enable or disable Telescope data storage.
|
*/
'enabled' => env('TELESCOPE_ENABLED', false),
/*
|--------------------------------------------------------------------------
| Telescope Domain
|--------------------------------------------------------------------------
|
| This is the subdomain where Telescope will be accessible from. If the
| setting is null, Telescope will reside under the same domain as the
| application. Otherwise, this value will be used as the subdomain.
|
*/
'domain' => env('TELESCOPE_DOMAIN'),
/*
|--------------------------------------------------------------------------
| Telescope Path
|--------------------------------------------------------------------------
|
| This is the URI path where Telescope will be accessible from. Feel free
| to change this path to anything you like. Note that the URI will not
| affect the paths of its internal API that aren't exposed to users.
|
*/
'path' => env('TELESCOPE_PATH', 'telescope'),
/*
|--------------------------------------------------------------------------
| Telescope Storage Driver
|--------------------------------------------------------------------------
|
| This configuration options determines the storage driver that will
| be used to store Telescope's data. In addition, you may set any
| custom options as needed by the particular driver you choose.
|
*/
'driver' => env('TELESCOPE_DRIVER', 'database'),
'storage' => [
'database' => [
'connection' => env('DB_CONNECTION', 'mysql'),
'chunk' => 1000,
],
],
/*
|--------------------------------------------------------------------------
| Telescope Queue
|--------------------------------------------------------------------------
|
| This configuration options determines the queue connection and queue
| which will be used to process ProcessPendingUpdate jobs. This can
| be changed if you would prefer to use a non-default connection.
|
*/
'queue' => [
'connection' => env('TELESCOPE_QUEUE_CONNECTION', null),
'queue' => env('TELESCOPE_QUEUE', null),
],
/*
|--------------------------------------------------------------------------
| Telescope Route Middleware
|--------------------------------------------------------------------------
|
| These middleware will be assigned to every Telescope route, giving you
| the chance to add your own middleware to this list or change any of
| the existing middleware. Or, you can simply stick with this list.
|
*/
'middleware' => [
'web',
Authorize::class,
],
/*
|--------------------------------------------------------------------------
| Allowed / Ignored Paths & Commands
|--------------------------------------------------------------------------
|
| The following array lists the URI paths and Artisan commands that will
| not be watched by Telescope. In addition to this list, some Laravel
| commands, like migrations and queue commands, are always ignored.
|
*/
'only_paths' => [
// 'api/*'
],
'ignore_paths' => [
'livewire*',
'nova-api*',
'pulse*',
],
'ignore_commands' => [
//
],
/*
|--------------------------------------------------------------------------
| Telescope Watchers
|--------------------------------------------------------------------------
|
| The following array lists the "watchers" that will be registered with
| Telescope. The watchers gather the application's profile data when
| a request or task is executed. Feel free to customize this list.
|
*/
'watchers' => [
Watchers\BatchWatcher::class => env('TELESCOPE_BATCH_WATCHER', true),
Watchers\CacheWatcher::class => [
'enabled' => env('TELESCOPE_CACHE_WATCHER', true),
'hidden' => [],
],
Watchers\ClientRequestWatcher::class => env('TELESCOPE_CLIENT_REQUEST_WATCHER', true),
Watchers\CommandWatcher::class => [
'enabled' => env('TELESCOPE_COMMAND_WATCHER', true),
'ignore' => [],
],
Watchers\DumpWatcher::class => [
'enabled' => env('TELESCOPE_DUMP_WATCHER', true),
'always' => env('TELESCOPE_DUMP_WATCHER_ALWAYS', false),
],
Watchers\EventWatcher::class => [
'enabled' => env('TELESCOPE_EVENT_WATCHER', true),
'ignore' => [],
],
Watchers\ExceptionWatcher::class => env('TELESCOPE_EXCEPTION_WATCHER', true),
Watchers\GateWatcher::class => [
'enabled' => env('TELESCOPE_GATE_WATCHER', true),
'ignore_abilities' => [],
'ignore_packages' => true,
'ignore_paths' => [],
],
Watchers\JobWatcher::class => env('TELESCOPE_JOB_WATCHER', true),
Watchers\LogWatcher::class => [
'enabled' => env('TELESCOPE_LOG_WATCHER', true),
'level' => 'error',
],
Watchers\MailWatcher::class => env('TELESCOPE_MAIL_WATCHER', true),
Watchers\ModelWatcher::class => [
'enabled' => env('TELESCOPE_MODEL_WATCHER', true),
'events' => ['eloquent.*'],
'hydrations' => true,
],
Watchers\NotificationWatcher::class => env('TELESCOPE_NOTIFICATION_WATCHER', true),
Watchers\QueryWatcher::class => [
'enabled' => env('TELESCOPE_QUERY_WATCHER', true),
'ignore_packages' => true,
'ignore_paths' => [],
'slow' => 100,
],
Watchers\RedisWatcher::class => env('TELESCOPE_REDIS_WATCHER', true),
Watchers\RequestWatcher::class => [
'enabled' => env('TELESCOPE_REQUEST_WATCHER', true),
'size_limit' => env('TELESCOPE_RESPONSE_SIZE_LIMIT', 64),
'ignore_http_methods' => [],
'ignore_status_codes' => [],
],
Watchers\ScheduleWatcher::class => env('TELESCOPE_SCHEDULE_WATCHER', true),
Watchers\ViewWatcher::class => env('TELESCOPE_VIEW_WATCHER', true),
],
];

View file

@ -0,0 +1,70 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Get the migration connection name.
*/
public function getConnection(): ?string
{
return config('telescope.storage.database.connection');
}
/**
* Run the migrations.
*/
public function up(): void
{
$schema = Schema::connection($this->getConnection());
$schema->create('telescope_entries', function (Blueprint $table) {
$table->bigIncrements('sequence');
$table->uuid('uuid');
$table->uuid('batch_id');
$table->string('family_hash')->nullable();
$table->boolean('should_display_on_index')->default(true);
$table->string('type', 20);
$table->longText('content');
$table->dateTime('created_at')->nullable();
$table->unique('uuid');
$table->index('batch_id');
$table->index('family_hash');
$table->index('created_at');
$table->index(['type', 'should_display_on_index']);
});
$schema->create('telescope_entries_tags', function (Blueprint $table) {
$table->uuid('entry_uuid');
$table->string('tag');
$table->primary(['entry_uuid', 'tag']);
$table->index('tag');
$table->foreign('entry_uuid')
->references('uuid')
->on('telescope_entries')
->onDelete('cascade');
});
$schema->create('telescope_monitoring', function (Blueprint $table) {
$table->string('tag')->primary();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
$schema = Schema::connection($this->getConnection());
$schema->dropIfExists('telescope_entries_tags');
$schema->dropIfExists('telescope_entries');
$schema->dropIfExists('telescope_monitoring');
}
};

View file

@ -19,3 +19,64 @@
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
## contrôle du cache navigateur - Expire headers
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 7200 seconds"
# Images
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
# Video
ExpiresByType video/webm "access plus 1 year"
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType video/mpeg "access plus 1 year"
# Fonts
ExpiresByType font/ttf "access plus 1 year"
ExpiresByType font/otf "access plus 1 year"
ExpiresByType font/woff "access plus 1 year"
ExpiresByType font/woff2 "access plus 1 year"
ExpiresByType application/font-woff "access plus 1 year"
# Icons
AddType image/x-icon .ico
ExpiresByType image/ico "access plus 1 year"
ExpiresByType image/icon "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
# CSS, JavaScript
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType text/html "access plus 7200 seconds"
ExpiresByType application/xhtml+xml "access plus 7200 seconds"
# Others
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType image/vnd.microsoft.icon "access plus 1 year"
</IfModule>
<IfModule mod_headers.c>
<FilesMatch "\\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "max-age=2592000, public"
</FilesMatch>
<FilesMatch "\\.(css)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
<FilesMatch "\\.(js)$">
Header set Cache-Control "max-age=216000, private"
</FilesMatch>
</IfModule>
<IfModule mod_deflate.c>
<FilesMatch "\.(ttf|otf|eot|svg)$" >
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>

View file

@ -22,12 +22,12 @@
</div> --}}
{{-- LASTNAME --}}
@if(!in_array('lastname', $hideFields))
@if (!in_array('lastname', $hideFields))
<label for="info-lastname" @class(array_merge(['mb-3', Arr::first($columns)]))>{{ __('Nom') }} *</label>
<div @class(array_merge(['mb-3', Arr::last($columns)]))>
<input class="form-control @if ($errors->has('lastname')) is-invalid @endif mx-auto" id="info-lastname"
name="lastname" type="text" value="{{ old('lastname', $crmCustomer->lastname ?? null) }}"
aria-label="{{ __('Nom') }}" autocomplete="family-name" required />
<input class="form-control @if ($errors->has('lastname')) is-invalid @endif mx-auto" id="info-lastname" name="lastname"
type="text" value="{{ old('lastname', $crmCustomer->lastname ?? null) }}" aria-label="{{ __('Nom') }}"
autocomplete="family-name" required />
@foreach ($errors->get('lastname') as $message)
<div class="invalid-feedback">{{ $message }}</div>
@endforeach
@ -35,12 +35,12 @@
@endif
{{-- FIRSTNAME --}}
@if(!in_array('firstname', $hideFields))
@if (!in_array('firstname', $hideFields))
<label for="info-firstname" @class(array_merge(['mb-3', Arr::first($columns)]))>{{ __('Prénom') }} *</label>
<div @class(array_merge(['mb-3', Arr::last($columns)]))>
<input class="form-control @if ($errors->has('firstname')) is-invalid @endif mx-auto" id="info-firstname"
name="firstname" type="text" value="{{ old('firstname', $crmCustomer->firstname ?? null) }}"
aria-label="{{ __('Prénom') }}" autocomplete="given-name" required />
<input class="form-control @if ($errors->has('firstname')) is-invalid @endif mx-auto" id="info-firstname" name="firstname"
type="text" value="{{ old('firstname', $crmCustomer->firstname ?? null) }}" aria-label="{{ __('Prénom') }}"
autocomplete="given-name" required />
@foreach ($errors->get('firstname') as $message)
<div class="invalid-feedback">{{ $message }}</div>
@endforeach
@ -48,13 +48,12 @@
@endif
{{-- PSEUDO --}}
@if(!in_array('username', $hideFields))
@if (!in_array('username', $hideFields))
<label for="info-username" @class(array_merge(['mb-3', Arr::first($columns)]))>{{ __('Pseudo') }} *</label>
<div @class(array_merge(['mb-3', Arr::last($columns)]))>
<input class="form-control @if ($errors->has('username')) is-invalid @endif mx-auto" id="info-username"
name="username" data-form-type="username" type="text"
value="{{ old('username', $customer->username ?? null) }}" aria-label="{{ __('Pseudo') }}"
autocomplete="username" required />
<input class="form-control @if ($errors->has('username')) is-invalid @endif mx-auto" id="info-username" name="username"
data-form-type="username" type="text" value="{{ old('username', $customer->username ?? null) }}"
aria-label="{{ __('Pseudo') }}" autocomplete="username" required />
@foreach ($errors->get('username') as $message)
<div class="invalid-feedback">{{ $message }}</div>
@endforeach
@ -62,13 +61,12 @@
@endif
{{-- EMAIL --}}
@if(!in_array('email', $hideFields))
@if (!in_array('email', $hideFields))
<label for="info-email" @class(array_merge(['mb-3', Arr::first($columns)]))>{{ __('Email Address') }} *</label>
<div @class(array_merge(['mb-3', Arr::last($columns)]))>
<input class="form-control @if ($errors->has('email')) is-invalid @endif mx-auto" id="info-email"
name="email" data-form-type="email" type="text"
value="{{ old('email', $crmCustomer->email ?? null) }}" aria-label="{{ __('Email Address') }}"
autocomplete="email" required />
<input class="form-control @if ($errors->has('email')) is-invalid @endif mx-auto" id="info-email" name="email"
data-form-type="email" type="text" value="{{ old('email', $crmCustomer->email ?? null) }}"
aria-label="{{ __('Email Address') }}" autocomplete="email" required />
@foreach ($errors->get('email') as $message)
<div class="invalid-feedback">{{ $message }}</div>
@endforeach
@ -76,7 +74,7 @@
@endif
{{-- BIRTHDAY --}}
@if(!in_array('birth_date', $hideFields))
@if (!in_array('birth_date', $hideFields))
<label class="col-sm-4 col-md-2 mb-3" for="info-birthdate">
{{ str(__('validation.attributes.birthday'))->ucFirst() }} *
</label>
@ -99,14 +97,14 @@
@endif
{{-- PHONE --}}
@if(!in_array('phone', $hideFields))
@if (!in_array('phone', $hideFields))
<label for="info-phone" @class(array_merge(['mb-3', Arr::first($columns)]))>
{{ str(__('validation.attributes.phone'))->ucFirst() }} *
</label>
<div @class(array_merge(['mb-3', Arr::last($columns)]))>
<input class="form-control @if ($errors->has('phone')) is-invalid @endif mx-auto" id="info-phone"
name="phone" type="text" value="{{ old('phone', $crmCustomer->phone ?? null) }}"
aria-label="{{ __('validation.attributes.phone') }}" autocomplete="phone-line1" required />
<input class="form-control @if ($errors->has('phone')) is-invalid @endif mx-auto" id="info-phone" name="phone"
type="text" value="{{ old('phone', $crmCustomer->phone ?? null) }}" aria-label="{{ __('validation.attributes.phone') }}"
autocomplete="phone-line1" required />
@foreach ($errors->get('phone') as $message)
<div class="invalid-feedback">{{ $message }}</div>
@endforeach
@ -114,13 +112,13 @@
@endif
{{-- ADDRESS --}}
@if(!in_array('address', $hideFields))
@if (!in_array('address', $hideFields))
<label for="info-address" @class(array_merge(['mb-3', Arr::first($columns)]))>
{{ str(__('validation.attributes.line_address_1'))->ucFirst() }} *
</label>
<div @class(array_merge(['mb-3', Arr::last($columns)]))>
<input class="form-control @if ($errors->has('address')) is-invalid @endif mx-auto" id="info-address"
name="address" type="text" value="{{ old('address', $crmCustomer->address ?? null) }}"
<input class="form-control @if ($errors->has('address')) is-invalid @endif mx-auto" id="info-address" name="address"
type="text" value="{{ old('address', $crmCustomer->address ?? null) }}"
aria-label="{{ __('validation.attributes.line_address_1') }}" autocomplete="address-line1" required />
@foreach ($errors->get('address') as $message)
<div class="invalid-feedback">{{ $message }}</div>
@ -129,13 +127,13 @@
@endif
{{-- ADDRESS 2 --}}
@if(!in_array('address2', $hideFields))
@if (!in_array('address2', $hideFields))
<label for="info-address2" @class(array_merge(['mb-3', Arr::first($columns)]))>
{{ str(__('validation.attributes.line_address_2'))->ucFirst() }}
</label>
<div @class(array_merge(['mb-3', Arr::last($columns)]))>
<input class="form-control @if ($errors->has('address2')) is-invalid @endif mx-auto" id="info-address2"
name="address2" type="text" value="{{ old('address2', $crmCustomer->address2 ?? null) }}"
<input class="form-control @if ($errors->has('address2')) is-invalid @endif mx-auto" id="info-address2" name="address2"
type="text" value="{{ old('address2', $crmCustomer->address2 ?? null) }}"
aria-label="{{ __('validation.attributes.line_address_2') }}" autocomplete="address-line2" />
@foreach ($errors->get('address2') as $message)
<div class="invalid-feedback">{{ $message }}</div>
@ -144,29 +142,29 @@
@endif
{{-- POSTCODE --}}
@if(!in_array('postcode', $hideFields))
@if (!in_array('postal_code', $hideFields))
<label for="info-postalcode" @class(array_merge(['mb-3', Arr::first($columns)]))>
{{ str(__('validation.attributes.postal_code'))->ucFirst() }} *
</label>
<div @class(array_merge(['mb-3', Arr::last($columns)]))>
<input class="form-control @if ($errors->has('postcode')) is-invalid @endif mx-auto" id="info-postalcode"
name="postcode" type="text" value="{{ old('postcode', $crmCustomer->postcode ?? null) }}"
<input class="form-control @if ($errors->has('postal_code')) is-invalid @endif mx-auto" id="info-postalcode" name="postal_code"
type="text" value="{{ old('postal_code', $crmCustomer->postcode ?? null) }}"
aria-label="{{ __('validation.attributes.postal_code') }}" autocomplete="postal-code" required />
@foreach ($errors->get('postcode') as $message)
@foreach ($errors->get('postal_code') as $message)
<div class="invalid-feedback">{{ $message }}</div>
@endforeach
</div>
@endif
{{-- CITY --}}
@if(!in_array('city', $hideFields))
@if (!in_array('city', $hideFields))
<label for="info-city" @class(array_merge(['mb-3', Arr::first($columns)]))>
{{ str(__('validation.attributes.city'))->ucFirst() }} *
</label>
<div @class(array_merge(['mb-3', Arr::last($columns)]))>
<input class="form-control @if ($errors->has('city')) is-invalid @endif mx-auto" id="info-city"
name="city" type="text" value="{{ old('city', $crmCustomer->city ?? null) }}"
aria-label="{{ __('validation.attributes.city') }}" autocomplete="address-level2" required />
<input class="form-control @if ($errors->has('city')) is-invalid @endif mx-auto" id="info-city" name="city"
type="text" value="{{ old('city', $crmCustomer->city ?? null) }}" aria-label="{{ __('validation.attributes.city') }}"
autocomplete="address-level2" required />
@foreach ($errors->get('city') as $message)
<div class="invalid-feedback">{{ $message }}</div>
@endforeach
@ -174,7 +172,7 @@
@endif
{{-- COUNTRY --}}
@if(!in_array('country', $hideFields))
@if (!in_array('country', $hideFields))
<label for="info-country" @class(array_merge(['mb-3', Arr::first($columns)]))>
{{ str(__('validation.attributes.country'))->ucFirst() }} *
</label>
@ -182,14 +180,9 @@
@php
// * Avoir les DROM-COM + France
$franceCountries = collect(\LDC\LDCCRM\Enums\Country::getValidCountries())->filter(
fn($enum) => !in_array($enum, [
LDC\LDCCRM\Enums\Country::belgium,
LDC\LDCCRM\Enums\Country::luxembourg,
]),
);
$countries = collect(\LDC\LDCCRM\Enums\Country::getValidCountries())->filter(
fn($enum) => !$franceCountries->contains($enum),
fn($enum) => !in_array($enum, [LDC\LDCCRM\Enums\Country::belgium, LDC\LDCCRM\Enums\Country::luxembourg]),
);
$countries = collect(\LDC\LDCCRM\Enums\Country::getValidCountries())->filter(fn($enum) => !$franceCountries->contains($enum));
$old_country = old('country', optional($crmCustomer->country ?? null)->value ?: null);
@endphp
<select id="country" name="country" aria-label="{{ str(__('validation.attributes.country'))->ucFirst() }}"