<?php

namespace App\Domain\Website\Models;

use App\Domain\Shared\Traits\BelongsToAcademy;
use App\Domain\Website\Enums\SectionKey;
use Illuminate\Database\Eloquent\Model;

class WebsiteSection extends Model
{
    use BelongsToAcademy;

    protected $fillable = [
        'academy_id',
        'section_key',
        'title',
        'title_en',
        'subtitle',
        'subtitle_en',
        'content',
        'content_en',
        'settings',
        'sort_order',
        'is_enabled',
    ];

    protected $casts = [
        'section_key' => SectionKey::class,
        'settings' => 'array',
        'sort_order' => 'integer',
        'is_enabled' => 'boolean',
    ];

    public function getSetting(string $key, $default = null)
    {
        return data_get($this->settings, $key, $default);
    }
}
