<?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',
        'bg_type',
        'bg_color',
        'bg_gradient_from',
        'bg_gradient_to',
        'bg_gradient_angle',
        'bg_image_path',
        'bg_overlay_opacity',
        'bg_video_url',
        'animation',
        'padding_y',
        'hidden_on_mobile',
    ];

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

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