<?php

namespace App\Models;

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

class Coupon extends Model
{
    use HasFactory;

    protected $fillable = [
        'code',
        'expire_date',
        'disabled',
        'discount',
        'application_id',
        'dealer_id',
        'type',
        'value',
        'max_discount',
        'min_order_value',
        'usage_limit',
        'used',
        'dealer_id',
    ];

    protected $casts = [
        'expire_date' => 'datetime',
        'disabled' => 'boolean',
    ];

    public function application()
    {
        return $this->belongsTo(Application::class);
    }

    public function dealer()
    {
        return $this->belongsTo(User::class);
    }
}
