CluPilotCloud/app/Models/InvoiceExport.php

35 lines
922 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* Whether one invoice reached one destination.
*
* A row per pair rather than a flag on the invoice: an invoice is not
* "exported", it is on this target and not yet on that one — which is the only
* interesting question once there is more than one, and the only thing the
* sweep can act on.
*/
class InvoiceExport extends Model
{
protected $fillable = ['invoice_id', 'export_target_id', 'exported_at', 'error', 'attempts'];
protected function casts(): array
{
return ['exported_at' => 'datetime', 'attempts' => 'integer'];
}
public function invoice(): BelongsTo
{
return $this->belongsTo(Invoice::class);
}
public function target(): BelongsTo
{
return $this->belongsTo(ExportTarget::class, 'export_target_id');
}
}