<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class School extends Model
{
    protected $fillable = [
        'kcd_id', 'kab_kota_id', 'npsn', 'name', 'level', 'status', 
        'address', 'phone', 'email', 'principal_name', 'principal_nip', 
        'principal_phone', 'has_uld', 'uld_count', 'is_active',
        'profile_locked', 'profile_updated_at'
    ];

    protected $casts = [
        'is_active' => 'boolean',
        'has_uld' => 'boolean',
        'uld_count' => 'integer',
        'profile_locked' => 'boolean',
        'profile_updated_at' => 'datetime',
    ];

    public function kcd()
    {
        return $this->belongsTo(Kcd::class);
    }

    public function kabKota()
    {
        return $this->belongsTo(KabKota::class);
    }

    public function supervisorAssignments()
    {
        return $this->hasMany(SupervisorSchoolAssignment::class);
    }

    public function employeeAssignments()
    {
        return $this->hasMany(EmployeeAssignment::class);
    }

    public function sptjmReports()
    {
        return $this->hasMany(SptjmReport::class);
    }

    public function formResponses()
    {
        return $this->hasMany(FormResponse::class);
    }

    public function supervisorSchoolAssignments()
    {
        return $this->hasMany(SupervisorSchoolAssignment::class);
    }

    /**
     * Relationship: Has many Daya Tampung records
     */
    public function dayaTampung()
    {
        return $this->hasMany(DayaTampung::class);
    }

    /**
     * Relationship: Has many students
     */
    public function students()
    {
        return $this->hasMany(Student::class);
    }

    /**
     * Relationship: Has many ULD locations
     */
    public function uldLocations()
    {
        return $this->hasMany(UldLocation::class);
    }
}
