<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use App\Models\Concerns\LogsActivity;

class Coupon extends Model
{
    use LogsActivity;

    public function getActivityLogDescription(string $action): string
    {
        return sprintf('Coupon "%s" %s', $this->code, $action);
    }

    protected $fillable = [
        'code',
        'type',
        'value',
        'min_amount',
        'starts_at',
        'expires_at',
        'is_active',
    ];

    protected $casts = [
        'value' => 'decimal:2',
        'min_amount' => 'decimal:2',
        'starts_at' => 'datetime',
        'expires_at' => 'datetime',
        'is_active' => 'boolean',
    ];
}
