<?php

namespace App\Models;

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

class DiscountCode extends Model
{
    use HasFactory;

    protected $fillable = [
        'code',
        'type',
        'value',
        'max_discount',
        'min_purchase',
        'usage_limit',
        'used_count',
        'per_user_limit',
        'valid_from',
        'valid_until',
        'applicable_packages',
        'status',
    ];

    protected $casts = [
        'valid_from' => 'datetime',
        'valid_until' => 'datetime',
        'applicable_packages' => 'array',
    ];

    public function payments()
    {
        return $this->hasMany(Payment::class);
    }
}
