<?php

namespace App\Models;

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

class OnlineCourse extends Model
{
    use HasFactory;

    protected $fillable = [
        'department_id',
        'faculty_id',
        'course',
        'offered_by',
        'start_date',
        'end_date',
        'num_days',
        'proof'
    ];

    protected $casts = [
        'start_date' => 'date',
        'end_date' => 'date',
    ];

    // Relationship with User (Faculty)
    public function user()
    {
        return $this->belongsTo(User::class, 'faculty_id');
    }

    // Relationship with Department
    public function department()
    {
        return $this->belongsTo(Department::class, 'department_id');
    }
}