<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\Activitylog\LogOptions;

class OnlineResources extends Model
{
    use SoftDeletes, LogsActivity;

    protected $fillable = [
        'program_id',
        'semester_id',
        'subject_id',
        'file',
        'file_name',
        'file_download_count',
        'file_category',
        'file_released_date',
        'file_link',
    ];

    protected $casts = [
        'file_download_count' => 'integer',
        'file_released_date' => 'date',
    ];

    public function program()
    {
        return $this->belongsTo(Program::class);
    }

    public function semester()
    {
        return $this->belongsTo(Semester::class);
    }

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

    public function getActivitylogOptions(): \Spatie\Activitylog\LogOptions
    {
        return \Spatie\Activitylog\LogOptions::defaults()->logAll();
    }
}
