<?php

namespace App\Models;

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

class DiaryQuickEntry extends Model
{
    use HasFactory, SoftDeletes;

    protected $table = 'diary_quick_entries';

    protected $fillable = [
        'entry_date',
        'task_type',
        'task_title',
        'assigned_to',
        'notes',
        'is_completed',
        'completed_at',
        'completed_by',
        'created_by',
        'updated_by',
    ];

    protected $casts = [
        'entry_date' => 'date',
        'is_completed' => 'boolean',
        'completed_at' => 'datetime',
        'completed_by' => 'integer',
    ];

    public function assignedUser()
    {
        return $this->belongsTo(User::class, 'assigned_to');
    }

    public function creator()
    {
        return $this->belongsTo(User::class, 'created_by');
    }

    public function updater()
    {
        return $this->belongsTo(User::class, 'updated_by');
    }
}
