Your IP : 216.73.216.79


Current Path : /var/www/html/dynaweb-cms-v1/app/Models/Backend/
Upload File :
Current File : /var/www/html/dynaweb-cms-v1/app/Models/Backend/FrontendSite.php

<?php

namespace App\Models\Backend;

use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

#[Table('frontend_sites')]
#[Fillable([
    'name', 'slug', 'header_fk', 'footer_fk', 'layout',
    'status', 'is_default', 'sort_order',
])]
class FrontendSite extends Model
{
    use HasFactory;

    protected function casts(): array
    {
        return [
            'status' => 'boolean',
            'is_default' => 'boolean',
            'sort_order' => 'integer',
        ];
    }

    public function header()
    {
        return $this->belongsTo(FrontendComponent::class, 'header_fk');
    }

    public function footer()
    {
        return $this->belongsTo(FrontendComponent::class, 'footer_fk');
    }

    public function pages()
    {
        return $this->hasMany(FrontendPage::class, 'site_fk');
    }

    public function defaultPage()
    {
        return $this->hasOne(FrontendPage::class, 'site_fk')->where('is_default', true);
    }
}