<?php

namespace App\Models;

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

class StudyGuide extends Model
{
    use HasFactory, SoftDeletes;

    protected $table = 'study_guides';

    protected $fillable = ['teacher_id','study_guide_name','class_id', 'year','section', 'subject_id', 'file','is_active'];
    
    protected $casts = [
        'teacher_id' => 'integer',
        'class_id' => 'integer',
        'subject_id' => 'integer',
        'is_active' => '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')->withTrashed();
    }

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