From 05e667df5b28ec6046c458b29f5c3b039be0c907 Mon Sep 17 00:00:00 2001 From: Alexis Gousseau Date: Thu, 6 Jun 2024 11:12:12 +0200 Subject: [PATCH] fix: :art: resolve phpcs errors --- .../Controllers/Bo/ApproachController.php | 24 ++++++++++++++----- .../Bo/Approaches/UpdateApproachRequest.php | 4 +++- .../StaticPages/UpdateStaticPageRequest.php | 1 + app/Models/Approach.php | 2 +- app/Models/StaticPage.php | 4 ++-- phpcs.xml | 1 + 6 files changed, 26 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/Bo/ApproachController.php b/app/Http/Controllers/Bo/ApproachController.php index 97fe2873..b961a93a 100644 --- a/app/Http/Controllers/Bo/ApproachController.php +++ b/app/Http/Controllers/Bo/ApproachController.php @@ -96,14 +96,18 @@ class ApproachController extends Controller return redirect()->route('bo.approaches.edit', $approach) ->with('success', trans('crud.messages.has_been_created', [ 'model' => Str::ucfirst( - trans(ApproachTypeEnum::demarche->equals($approach->type) ? 'validation.custom.demarche' : 'validation.custom.label') + trans(ApproachTypeEnum::demarche->equals($approach->type) + ? 'validation.custom.demarche' + : 'validation.custom.label') ) ])); } return redirect()->back() ->with('error', trans('crud.messages.cannot_be_created', [ 'model' => Str::ucfirst( - trans(ApproachTypeEnum::demarche->equals($approach->type) ? 'validation.custom.demarche' : 'validation.custom.label') + trans(ApproachTypeEnum::demarche->equals($approach->type) + ? 'validation.custom.demarche' + : 'validation.custom.label') ) ])); }); @@ -136,14 +140,18 @@ class ApproachController extends Controller return redirect()->route('bo.approaches.edit', $approach) ->with('success', trans('crud.messages.has_been_updated', [ 'model' => Str::ucfirst( - trans(ApproachTypeEnum::demarche->equals($approach->type) ? 'validation.custom.demarche' : 'validation.custom.label') + trans(ApproachTypeEnum::demarche->equals($approach->type) + ? 'validation.custom.demarche' + : 'validation.custom.label') ) ])); } return redirect()->route('bo.approaches.edit', $approach) ->with('error', trans('crud.messages.cannot_be_updated', [ 'model' => Str::ucfirst( - trans(ApproachTypeEnum::demarche->equals($approach->type) ? 'validation.custom.demarche' : 'validation.custom.label') + trans(ApproachTypeEnum::demarche->equals($approach->type) + ? 'validation.custom.demarche' + : 'validation.custom.label') ) ])); }); @@ -166,14 +174,18 @@ class ApproachController extends Controller $previousQueries ))->with('success', trans('crud.messages.has_been_deleted', [ 'model' => Str::ucfirst( - trans(ApproachTypeEnum::demarche->equals($approach->type) ? 'validation.custom.demarche' : 'validation.custom.label') + trans(ApproachTypeEnum::demarche->equals($approach->type) + ? 'validation.custom.demarche' + : 'validation.custom.label') ) ])); } return redirect()->back() ->with('error', trans('crud.messages.cannot_be_deleted', [ 'model' => Str::ucfirst( - trans(ApproachTypeEnum::demarche->equals($approach->type) ? 'validation.custom.demarche' : 'validation.custom.label') + trans(ApproachTypeEnum::demarche->equals($approach->type) + ? 'validation.custom.demarche' + : 'validation.custom.label') ) ])); } diff --git a/app/Http/Requests/Bo/Approaches/UpdateApproachRequest.php b/app/Http/Requests/Bo/Approaches/UpdateApproachRequest.php index 6362397a..10a12c9d 100644 --- a/app/Http/Requests/Bo/Approaches/UpdateApproachRequest.php +++ b/app/Http/Requests/Bo/Approaches/UpdateApproachRequest.php @@ -13,8 +13,10 @@ class UpdateApproachRequest extends StoreApproachRequest */ protected function prepareForValidation(): void { + /** @var \App\Models\Approach $approachModel */ + $approachModel = $this->route()->parameter('approach'); $this->merge([ - 'type' => intval($this->route()->parameter('approach')->type->value), + 'type' => intval($approachModel->type->value), 'published' => $this->boolean('published') ]); $this->mergePicture('picture'); diff --git a/app/Http/Requests/Bo/StaticPages/UpdateStaticPageRequest.php b/app/Http/Requests/Bo/StaticPages/UpdateStaticPageRequest.php index 6e58b94c..03ea2795 100644 --- a/app/Http/Requests/Bo/StaticPages/UpdateStaticPageRequest.php +++ b/app/Http/Requests/Bo/StaticPages/UpdateStaticPageRequest.php @@ -10,6 +10,7 @@ use Illuminate\Support\Str; class UpdateStaticPageRequest extends FormRequest { use HasPicture; + /** * Determine if the user is authorized to make this request. * diff --git a/app/Models/Approach.php b/app/Models/Approach.php index a828939b..99cc6d19 100644 --- a/app/Models/Approach.php +++ b/app/Models/Approach.php @@ -57,7 +57,7 @@ class Approach extends Model static::creating(function (self $approach) { $approach->picture = FileStorageHelper::storeFile($approach, $approach->picture, true); }); - static::updated(function (self $approach) { + static::updating(function (self $approach) { $approach->picture = FileStorageHelper::storeFile($approach, $approach->picture, true); }); static::updated(function (self $approach) { diff --git a/app/Models/StaticPage.php b/app/Models/StaticPage.php index cec38b36..aa5db19f 100644 --- a/app/Models/StaticPage.php +++ b/app/Models/StaticPage.php @@ -63,12 +63,12 @@ class StaticPage extends Model { static::creating(function (self $model) { self::assertTitleIsUnique($model->title); - $model->slug = Str::slug($model->title); + $model->slug = Str::slug($model->title); $model->picture = FileStorageHelper::storeFile($model, $model->picture, true); }); static::updating(function (self $model) { self::assertTitleIsUnique($model->title, $model->id); - $model->slug = Str::slug($model->title); + $model->slug = Str::slug($model->title); $model->picture = FileStorageHelper::storeFile($model, $model->picture, true); }); static::updated(function (self $model) { diff --git a/phpcs.xml b/phpcs.xml index 3e28d831..a06bee76 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -8,6 +8,7 @@ config/ database/factories routes/ + */vendor/*