<?php

namespace App\Models;

use App\Models\BaseModel;

class PrintRequest extends BaseModel
{
    protected $table = 'print_requests';

    // ✅ CI: useTimestamps = true (created_at/updated_at)
    public $timestamps = true;

    protected $fillable = [
        'teacher_id',
        'admin_id',
        'class_id',
        'file_path',
        'page_selection',
        'num_copies',
        'required_by',
        'pickup_method',
        'status',
        'created_at',
        'updated_at',
    ];

    protected $casts = [
        'teacher_id'    => 'integer',
        'admin_id'      => 'integer',
        'class_id'      => 'integer',
        'num_copies'    => 'integer',
        'required_by'   => 'datetime', // if stored as DATETIME
    ];

    /* Optional relationships */
    public function teacher()
    {
        return $this->belongsTo(User::class, 'teacher_id');
    }

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

    public function schoolClass()
    {
        return $this->belongsTo(SchoolClass::class, 'class_id');
    }
}