<?php

namespace Modules\Vrc\Entities;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

class VrcWarranty extends Model
{
    protected $table = 'vrc_warranties';
    protected $fillable = [
        'business_id', 'repair_order_id', 'vehicle_id', 'kind', 'ref_id',
        'description', 'start_date', 'end_date', 'terms',
    ];
    protected $casts = ['start_date' => 'date', 'end_date' => 'date'];

    /** Active = end_date today or later. */
    public function scopeActive(Builder $q): Builder
    {
        return $q->whereDate('end_date', '>=', now()->toDateString());
    }
}
