From f6dbb64a04691ca5971216ab0bd4952ce8c66be6 Mon Sep 17 00:00:00 2001 From: Vincent BRIDIER Date: Wed, 23 Oct 2024 17:55:57 +0200 Subject: [PATCH 1/6] feat: Add Expiration Headers on assets --- public/.htaccess | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/public/.htaccess b/public/.htaccess index 3aec5e27..d4398806 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -19,3 +19,64 @@ RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] + +## contrôle du cache navigateur - Expire headers + +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" + + + + +Header set Cache-Control "max-age=2592000, public" + + +Header set Cache-Control "max-age=604800, public" + + +Header set Cache-Control "max-age=216000, private" + + + + + +SetOutputFilter DEFLATE + + From 414b1efb175a84c978b462abce851913fb15bd0c Mon Sep 17 00:00:00 2001 From: Noah Lancien Date: Wed, 23 Oct 2024 16:05:53 +0000 Subject: [PATCH 2/6] fix: postcode field in customer infos form was broken --- .../Controllers/Club/CustomerController.php | 8 +- app/Models/Customer.php | 10 ++- .../partials/customer-fields.blade.php | 83 +++++++++---------- 3 files changed, 49 insertions(+), 52 deletions(-) diff --git a/app/Http/Controllers/Club/CustomerController.php b/app/Http/Controllers/Club/CustomerController.php index bf68820b..846abdae 100644 --- a/app/Http/Controllers/Club/CustomerController.php +++ b/app/Http/Controllers/Club/CustomerController.php @@ -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')); } } diff --git a/app/Models/Customer.php b/app/Models/Customer.php index 69aa1a32..5d5e5c7c 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -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(); diff --git a/resources/views/club/pages/customers/partials/customer-fields.blade.php b/resources/views/club/pages/customers/partials/customer-fields.blade.php index 3fd716b8..6ade574a 100644 --- a/resources/views/club/pages/customers/partials/customer-fields.blade.php +++ b/resources/views/club/pages/customers/partials/customer-fields.blade.php @@ -22,12 +22,12 @@ --}} {{-- LASTNAME --}} -@if(!in_array('lastname', $hideFields)) +@if (!in_array('lastname', $hideFields))
- + @foreach ($errors->get('lastname') as $message)
{{ $message }}
@endforeach @@ -35,12 +35,12 @@ @endif {{-- FIRSTNAME --}} -@if(!in_array('firstname', $hideFields)) +@if (!in_array('firstname', $hideFields))
- + @foreach ($errors->get('firstname') as $message)
{{ $message }}
@endforeach @@ -48,13 +48,12 @@ @endif {{-- PSEUDO --}} -@if(!in_array('username', $hideFields)) +@if (!in_array('username', $hideFields))
- + @foreach ($errors->get('username') as $message)
{{ $message }}
@endforeach @@ -62,13 +61,12 @@ @endif {{-- EMAIL --}} -@if(!in_array('email', $hideFields)) +@if (!in_array('email', $hideFields))
- + @foreach ($errors->get('email') as $message)
{{ $message }}
@endforeach @@ -76,7 +74,7 @@ @endif {{-- BIRTHDAY --}} -@if(!in_array('birth_date', $hideFields)) +@if (!in_array('birth_date', $hideFields)) @@ -99,14 +97,14 @@ @endif {{-- PHONE --}} -@if(!in_array('phone', $hideFields)) +@if (!in_array('phone', $hideFields))
- + @foreach ($errors->get('phone') as $message)
{{ $message }}
@endforeach @@ -114,13 +112,13 @@ @endif {{-- ADDRESS --}} -@if(!in_array('address', $hideFields)) +@if (!in_array('address', $hideFields))
- @foreach ($errors->get('address') as $message)
{{ $message }}
@@ -129,13 +127,13 @@ @endif {{-- ADDRESS 2 --}} -@if(!in_array('address2', $hideFields)) +@if (!in_array('address2', $hideFields))
- @foreach ($errors->get('address2') as $message)
{{ $message }}
@@ -144,29 +142,29 @@ @endif {{-- POSTCODE --}} -@if(!in_array('postcode', $hideFields)) +@if (!in_array('postal_code', $hideFields))
- - @foreach ($errors->get('postcode') as $message) + @foreach ($errors->get('postal_code') as $message)
{{ $message }}
@endforeach
@endif {{-- CITY --}} -@if(!in_array('city', $hideFields)) +@if (!in_array('city', $hideFields))
- + @foreach ($errors->get('city') as $message)
{{ $message }}
@endforeach @@ -174,7 +172,7 @@ @endif {{-- COUNTRY --}} -@if(!in_array('country', $hideFields)) +@if (!in_array('country', $hideFields)) @@ -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