<?php

namespace App\Models;

use App\Scopes\InstancedModel;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * @property string $id
 * @property string $tenant
 * @property int $invoice_id
 * @property int $cost_unit_id
 * @property float $amount
 * @property string $recipient_name
 * @property string $recipient_iban
 * @property string $payment_purpose
 * @property bool $exported
 * @property \DateTime|null $exported_at
 */
class SepaPaymentElement extends InstancedModel
{
    use HasUuids;

    public $incrementing = false;
    protected $keyType = 'string';

    protected $fillable = [
        'tenant',
        'invoice_id',
        'cost_unit_id',
        'amount',
        'recipient_name',
        'recipient_iban',
        'payment_purpose',
        'exported',
        'exported_at',
    ];

    protected $casts = [
        'exported' => 'boolean',
        'exported_at' => 'datetime',
    ];

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

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