<?php

namespace App\Models;

use App\Enums\RecordStatus;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class LinePlan extends Model
{
    use HasFactory;

    protected $fillable = [
        'line_id', 'plan_id', 'price_at_assignment', 'start_date', 'end_date', 'status',
    ];

    protected $casts = [
        'price_at_assignment' => 'decimal:2',
        'start_date' => 'date',
        'end_date' => 'date',
        'status' => RecordStatus::class,
    ];

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

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