<?php

namespace App\Models;

use App\Traits\HasLocalizedAttributes;
use Illuminate\Database\Eloquent\Model;

class School extends Model
{
    use HasLocalizedAttributes;

    protected $fillable = [
        'name_en',
        'name_ar',
        'slug',
        'logo',
        'title_en',
        'title_ar',
        'short_description_en',
        'short_description_ar',
        'description_en',
        'description_ar',
        'banner',
        'color',
        'vision_en',
        'vision_ar',
        'clarity_en',
        'clarity_ar',
        'technology_en',
        'technology_ar',
        'communication_en',
        'communication_ar',
        'about_en',
        'about_ar',
        'about_image',
        'gallery_description_en',
        'gallery_description_ar',
        'contact_description_en',
        'contact_description_ar',
        'meta_tags',
    ];

    protected $casts = [
        'meta_tags' => 'array',
    ];

    protected $localizable = [
        'name',
        'title',
        'short_description',
        'description',
        'vision',
        'clarity',
        'technology',
        'communication',
        'about',
        'gallery_description',
        'contact_description',
    ];

    // 🔗 Relationships
    public function galleries()
    {
        return $this->hasMany(SchoolGallery::class);
    }

    public function images(){
        return $this->galleries()->where('type', 'image')->get();
    }

    public function videos(){
        return $this->galleries()->where('type', 'video')->get();
    }

    public function contacts()
    {
        return $this->hasMany(SchoolContact::class);
    }
}
