<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Organization extends Model {
    protected $fillable=['parent_id','type','name','acronym','slug','logo_path','website','theme_color','email','phone','address','period_start','period_end','is_active','public_page_enabled','show_in_main_menu','aggregate_news','aggregate_events','aggregate_programs','aggregate_gallery','include_in_statistics','include_in_reports','sort_order','settings'];
    protected $casts=['period_start'=>'date','period_end'=>'date','is_active'=>'boolean','public_page_enabled'=>'boolean','show_in_main_menu'=>'boolean','aggregate_news'=>'boolean','aggregate_events'=>'boolean','aggregate_programs'=>'boolean','aggregate_gallery'=>'boolean','include_in_statistics'=>'boolean','include_in_reports'=>'boolean','settings'=>'array'];
    public function parent(): BelongsTo { return $this->belongsTo(self::class,'parent_id'); }
    public function children(): HasMany { return $this->hasMany(self::class,'parent_id'); }
    public function members(): HasMany { return $this->hasMany(Member::class); }
    public function news(): HasMany { return $this->hasMany(News::class); }
    public function letters(): HasMany { return $this->hasMany(Letter::class); }
    public function programs(): HasMany { return $this->hasMany(Program::class); }
    public function activities(): HasMany { return $this->hasMany(Activity::class); }
    public function attendanceSessions(): HasMany { return $this->hasMany(AttendanceSession::class); }
}
