takeone/app/Models/Invoice.php

61 lines
1.2 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Invoice extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'tenant_id',
'amount',
'status',
'due_date',
'student_user_id',
'payer_user_id',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'amount' => 'decimal:2',
'due_date' => 'date',
];
/**
* Get the tenant that owns the invoice.
*/
public function tenant(): BelongsTo
{
return $this->belongsTo(Tenant::class);
}
/**
* Get the student user that owns the invoice.
*/
public function student(): BelongsTo
{
return $this->belongsTo(User::class, 'student_user_id');
}
/**
* Get the payer user that owns the invoice.
*/
public function payer(): BelongsTo
{
return $this->belongsTo(User::class, 'payer_user_id');
}
}