<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Announcement extends Model
{
    use HasFactory;
    protected $table = 'announcements';

    protected $fillable = [
        'teacher_id',
        'class_id',
        'year',
        'section',
        'subject_id',
        'title',
        'description',
        'end_date'
    ];
    
    protected $casts = [
        'teacher_id' => 'integer',
        'class_id' => 'integer',
        'subject_id' => 'integer',
    ];


    public function teacher()
    {
        return $this->belongsTo(Teacher::class, 'teacher_id');
    }

    public function classRelation()
    {
        return $this->belongsTo(Classes::class, 'class_id')->withTrashed();
    }

    public function section()
    {
        return $this->belongsTo(Section::class, 'section_id');
    }

    public function subject()
    {
        return $this->belongsTo(Subject::class, 'subject_id')->withTrashed();
    }
}
