57 lines
1.1 KiB
PHP
57 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class PageBlock extends Model
|
|
{
|
|
public const TYPES = [
|
|
'hero',
|
|
'image',
|
|
'benefits',
|
|
'social_proof',
|
|
'form',
|
|
'countdown',
|
|
'text',
|
|
'cta_banner',
|
|
'divider',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'preregistration_page_id',
|
|
'type',
|
|
'content',
|
|
'sort_order',
|
|
'is_visible',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'content' => 'array',
|
|
'is_visible' => 'boolean',
|
|
];
|
|
}
|
|
|
|
public function preregistrationPage(): BelongsTo
|
|
{
|
|
return $this->belongsTo(PreregistrationPage::class);
|
|
}
|
|
|
|
/**
|
|
* Blade dynamic component name (kebab-case where needed).
|
|
*/
|
|
public function bladeComponentName(): string
|
|
{
|
|
return match ($this->type) {
|
|
'social_proof' => 'blocks.social-proof',
|
|
'cta_banner' => 'blocks.cta-banner',
|
|
default => 'blocks.'.$this->type,
|
|
};
|
|
}
|
|
}
|