2026-04-03 04:07:39 +07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
|
|
|
|
|
|
class CashRecord extends Model
|
|
|
|
|
{
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'amount', 'category_id', 'description',
|
|
|
|
|
'date', 'created_by', 'verified_by', 'verified_at',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
|
'date' => 'date',
|
|
|
|
|
'verified_at' => 'datetime',
|
|
|
|
|
];
|
|
|
|
|
|
2026-04-03 08:01:58 +07:00
|
|
|
protected static function booted(): void
|
|
|
|
|
{
|
|
|
|
|
static::creating(function (CashRecord $record) {
|
|
|
|
|
$record->created_by ??= auth()->id();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-03 04:07:39 +07:00
|
|
|
public function category(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(CashCategory::class, 'category_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function creator(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(User::class, 'created_by');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function verifier(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(User::class, 'verified_by');
|
|
|
|
|
}
|
|
|
|
|
}
|