<?php

namespace App\Domain\Pricing\Models;

use App\Domain\Shared\Traits\BelongsToAcademy;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class PromotionUsage extends Model
{
    use BelongsToAcademy;

    protected $fillable = [
        'academy_id',
        'promotion_id',
        'participant_id',
        'invoice_id',
        'discount_amount',
        'used_at',
        'metadata',
    ];

    protected $casts = [
        'discount_amount' => 'integer',
        'used_at' => 'datetime',
        'metadata' => 'array',
    ];

    // ─── Relationships ─────────────────────────────────────────────

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

    public function participant(): BelongsTo
    {
        return $this->belongsTo(\App\Domain\Participant\Models\Participant::class);
    }

    public function invoice(): BelongsTo
    {
        return $this->belongsTo(\App\Domain\Financial\Models\Invoice::class);
    }
}
