presseportale/app/Models/Invoice.php
Kevin Adametz 5b8bdf4182
Some checks are pending
linter / quality (push) Waiting to run
tests / ci (push) Waiting to run
12-05-2026 Frontend dev
2026-05-12 18:32:33 +02:00

62 lines
1.4 KiB
PHP

<?php
namespace App\Models;
use App\Enums\InvoiceStatus;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class Invoice extends Model
{
use HasFactory, SoftDeletes;
protected $fillable = [
'user_id',
'user_payment_id',
'invoice_billing_address_id',
'number',
'status',
'amount_cents',
'tax_cents',
'total_cents',
'currency',
'is_netto',
'invoice_date',
'due_date',
'paid_at',
'stripe_invoice_id',
'pdf_path',
];
protected function casts(): array
{
return [
'status' => InvoiceStatus::class,
'amount_cents' => 'integer',
'tax_cents' => 'integer',
'total_cents' => 'integer',
'is_netto' => 'boolean',
'invoice_date' => 'date',
'due_date' => 'date',
'paid_at' => 'datetime',
'deleted_at' => 'datetime',
];
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function userPayment(): BelongsTo
{
return $this->belongsTo(UserPayment::class, 'user_payment_id');
}
public function invoiceBillingAddress(): BelongsTo
{
return $this->belongsTo(InvoiceBillingAddress::class);
}
}