Implementa gestão Filament de configurações, serviços, portfólio e depoimentos com policies admin-only, upload validado e seed determinístico. Co-authored-by: Cursor <cursoragent@cursor.com>
61 lines
1.3 KiB
PHP
61 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Concerns\HasPublication;
|
|
use App\Policies\ServicePolicy;
|
|
use Database\Factories\ServiceFactory;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Attributes\UsePolicy;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Carbon;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* @property Carbon|null $published_at
|
|
* @property bool $is_featured
|
|
*/
|
|
#[Fillable([
|
|
'title',
|
|
'slug',
|
|
'summary',
|
|
'description',
|
|
'cover_image_path',
|
|
'cover_image_alt',
|
|
'sort_order',
|
|
'is_featured',
|
|
'published_at',
|
|
])]
|
|
#[UsePolicy(ServicePolicy::class)]
|
|
class Service extends Model
|
|
{
|
|
/** @use HasFactory<ServiceFactory> */
|
|
use HasFactory;
|
|
|
|
use HasPublication;
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::saving(function (Service $service): void {
|
|
if (blank($service->slug) && filled($service->title)) {
|
|
$service->slug = Str::slug($service->title);
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string|class-string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'is_featured' => 'boolean',
|
|
'published_at' => 'datetime',
|
|
'sort_order' => 'integer',
|
|
];
|
|
}
|
|
}
|