fix: 🐛 change the link for breeding show in breedings.blade
This commit is contained in:
parent
261b0674ea
commit
82c5d2831e
3 changed files with 41 additions and 4 deletions
|
|
@ -24,4 +24,19 @@ enum BreedingTypeEnum: int
|
|||
self::breedingFood->name => 'L\'alimentation des volailles',
|
||||
self::breedingHealth->name => 'La santé des volailles',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get all breeding pages.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getBreedingPages(): array
|
||||
{
|
||||
return [
|
||||
self::breedingPoultry,
|
||||
self::breedingJob,
|
||||
self::breedingFood,
|
||||
self::breedingHealth,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,8 +72,9 @@ class StaticPage extends Model
|
|||
throw new \RuntimeException("Creating a new page is not authorized");
|
||||
});
|
||||
static::updating(function (self $model) {
|
||||
self::assertTitleIsUnique($model->seo_title, $model->getKey());
|
||||
$model->slug = Str::slug($model->seo_title ?? $model->title ?? str()->random(20));
|
||||
self::assertSeoTitleIsUnique($model->seo_title, $model->getKey());
|
||||
self::assertTitleIsUnique($model->title, $model->getKey());
|
||||
$model->slug = Str::slug($model->title ?? $model->seo_title ?? str()->random(20));
|
||||
if (!is_null($model->picture)) {
|
||||
$model->picture = FileStorageHelper::storeFile($model, $model->picture, true);
|
||||
}
|
||||
|
|
@ -124,7 +125,7 @@ class StaticPage extends Model
|
|||
* @return void
|
||||
* @throws \Illuminate\Validation\ValidationException If an actu seo_title already exists.
|
||||
*/
|
||||
private static function assertTitleIsUnique(string|null $seo_title, ?int $id = null): void
|
||||
private static function assertSeoTitleIsUnique(string|null $seo_title, ?int $id = null): void
|
||||
{
|
||||
if (!is_null($seo_title)) {
|
||||
$table = (new self())->getTable();
|
||||
|
|
@ -133,6 +134,23 @@ class StaticPage extends Model
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts using validation that the title is unique
|
||||
*
|
||||
* @param string|null $seo_title
|
||||
* @param integer|null $id
|
||||
* @return void
|
||||
* @throws \Illuminate\Validation\ValidationException If an actu seo_title already exists.
|
||||
*/
|
||||
private static function assertTitleIsUnique(string|null $title, ?int $id = null): void
|
||||
{
|
||||
if (!is_null($title)) {
|
||||
$table = (new self())->getTable();
|
||||
ToolboxHelper::assertFieldIsUnique($table, 'title', $title, $id);
|
||||
ToolboxHelper::assertFieldIsUnique($table, 'slug', Str::slug($title), $id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset all cache elements related to this model.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -29,7 +29,11 @@
|
|||
],
|
||||
[
|
||||
'name' => __('L\'élevage de volailles'),
|
||||
'link' => route('fo.breeding.show', 'slug'),
|
||||
'link' => route(
|
||||
'fo.breeding.show',
|
||||
$breedingPages->where('type', \App\Enums\StaticPageType::breedingPoultry)->first()
|
||||
),
|
||||
|
||||
],
|
||||
[
|
||||
'name' => __('Le métier d\'élevage de volailles'),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue