73 lines
1.7 KiB
PHP
73 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\BreedingBlocType;
|
|
use App\Enums\BreedingPageType;
|
|
use App\Enums\InputType;
|
|
use App\Traits\MiniAcfModel;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Str;
|
|
use Kwaadpepper\Enum\Traits\CastsEnums;
|
|
|
|
class BreedingPage extends Model
|
|
{
|
|
use CastsEnums;
|
|
use HasFactory;
|
|
use MiniAcfModel;
|
|
|
|
protected $enumCasts = [
|
|
'type' => BreedingPageType::class,
|
|
'media_type' => InputType::class
|
|
];
|
|
|
|
protected $casts = [
|
|
'content' => 'array',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'title', 'headerContent',
|
|
'seo_title', 'seo_description',
|
|
'headerContent', 'subtitle',
|
|
'subtitleContent', 'media_type',
|
|
'picture', 'picture_alt', 'picture_title',
|
|
'video', 'content', 'status'
|
|
];
|
|
|
|
protected static function booted()
|
|
{
|
|
static::creating(function (BreedingPage $page) {
|
|
$page->slug = Str::slug($page->title);
|
|
});
|
|
static::updating(function (BreedingPage $page) {
|
|
$page->slug = Str::slug($page->title);
|
|
});
|
|
}
|
|
|
|
public function getRouteKeyName()
|
|
{
|
|
return 'slug';
|
|
}
|
|
|
|
/**
|
|
* Get Blocks Template Data
|
|
*
|
|
* @return array
|
|
*/
|
|
public static function getBlocks(): array
|
|
{
|
|
return [
|
|
BreedingBlocType::bloc1()->value => [
|
|
'type' => BreedingBlocType::bloc1(),
|
|
'content' => [
|
|
'dropdownArray' => [
|
|
'label' => 'Dropdowns',
|
|
'inputType' => InputType::dropdownArray(),
|
|
'value' => []
|
|
]
|
|
]
|
|
]
|
|
];
|
|
}
|
|
}
|