fix: 🎨 resolve phpcs errors

This commit is contained in:
Alexis Gousseau 2024-06-06 11:12:12 +02:00
parent 467478a8ba
commit 05e667df5b
6 changed files with 26 additions and 10 deletions

View file

@ -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')
)
]));
}

View file

@ -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');

View file

@ -10,6 +10,7 @@ use Illuminate\Support\Str;
class UpdateStaticPageRequest extends FormRequest
{
use HasPicture;
/**
* Determine if the user is authorized to make this request.
*

View file

@ -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) {

View file

@ -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) {

View file

@ -8,6 +8,7 @@
<file>config/</file>
<file>database/factories</file>
<file>routes/</file>
<exclude-pattern type="relative">*/vendor/*</exclude-pattern>
<rule ref="PSR1" />
<rule ref="PSR12" />