<?php

namespace App\Models;

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

class Reading extends Model
{
    use HasFactory;

    protected $fillable = [
        'printer_id', 'reading_date', 'bw_counter', 'color_counter', 'scan_counter',
        'technician_id',
        'toner_black', 'toner_cyan', 'toner_magenta', 'toner_yellow', 'description',
    ];

    protected function casts(): array
    {
        return ['reading_date' => 'date'];
    }

    public function printer(): BelongsTo
    {
        return $this->belongsTo(Printer::class);
    }

    public function technician(): BelongsTo
    {
        return $this->belongsTo(User::class, 'technician_id');
    }
}
