<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Teacher extends Model
{
    protected $fillable = [
        'user_id', 'school_id', 'tsc_no', 'employee_no',
        'department_id', 'joining_date', 'employment_type',
    ];

    protected $casts = ['joining_date' => 'date'];

    public function user() { return $this->belongsTo(User::class); }
    public function school() { return $this->belongsTo(School::class); }
    public function department() { return $this->belongsTo(Department::class); }
    public function assignments() { return $this->hasMany(Assignment::class); }
    public function timetables() { return $this->hasMany(Timetable::class); }
    public function subjectStreams() { return $this->hasMany(TeacherSubjectStream::class); }

    public function getNameAttribute(): string { return $this->user->name; }
}
