<?php

declare(strict_types=1);

namespace Kylin\Manufacturing\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Kylin\Manufacturing\Enums\MaintenanceType;

/**
 * 维护计划
 */
class MaintenancePlan extends Model
{
    protected $table = 'kylin_mfg_maintenance_plans';

    protected $fillable = [
        'equipment_id',
        'type',
        'content',
        'cycle_days',
        'next_date',
        'last_executed_at',
        'status',
    ];

    protected function casts(): array
    {
        return [
            'type' => MaintenanceType::class,
            'cycle_days' => 'integer',
            'next_date' => 'date',
            'last_executed_at' => 'datetime',
        ];
    }

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