diff --git a/app/Models/CashRecord.php b/app/Models/CashRecord.php index ea4c0a6..c53e270 100644 --- a/app/Models/CashRecord.php +++ b/app/Models/CashRecord.php @@ -17,6 +17,13 @@ class CashRecord extends Model 'verified_at' => 'datetime', ]; + protected static function booted(): void + { + static::creating(function (CashRecord $record) { + $record->created_by ??= auth()->id(); + }); + } + public function category(): BelongsTo { return $this->belongsTo(CashCategory::class, 'category_id');