Implemented a block editor for changing the layout of the page
This commit is contained in:
56
app/Models/PageBlock.php
Normal file
56
app/Models/PageBlock.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?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,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user