35 lines
833 B
PHP
35 lines
833 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Guarded;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Spatie\MediaLibrary\HasMedia;
|
|
use Spatie\MediaLibrary\InteractsWithMedia;
|
|
|
|
#[Guarded(['id'])]
|
|
class Expense extends Model implements HasMedia
|
|
{
|
|
use HasFactory, InteractsWithMedia, SoftDeletes;
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'amount' => 'integer',
|
|
];
|
|
}
|
|
|
|
public function cashTransaction(): BelongsTo
|
|
{
|
|
return $this->belongsTo(CashTransaction::class);
|
|
}
|
|
|
|
public function createdBy(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by_id');
|
|
}
|
|
}
|