43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\ExpenseCategory;
|
|
use App\Enums\FundingSource;
|
|
use Database\Factories\MedicationExpenseValueFactory;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
#[Fillable(['medication_expense_row_id', 'funding_source', 'expense_category', 'amount'])]
|
|
class MedicationExpenseValue extends Model
|
|
{
|
|
/** @use HasFactory<MedicationExpenseValueFactory> */
|
|
use HasFactory;
|
|
|
|
/**
|
|
* Get the row that owns the value.
|
|
*
|
|
* @return BelongsTo<MedicationExpenseRow, $this>
|
|
*/
|
|
public function medicationExpenseRow(): BelongsTo
|
|
{
|
|
return $this->belongsTo(MedicationExpenseRow::class);
|
|
}
|
|
|
|
/**
|
|
* Get the attributes that should be cast.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'amount' => 'decimal:2',
|
|
'funding_source' => FundingSource::class,
|
|
'expense_category' => ExpenseCategory::class,
|
|
];
|
|
}
|
|
}
|