first change

This commit is contained in:
2025-07-27 17:40:56 +05:45
commit f8b9a6725b
3152 changed files with 229528 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Traits;
use Illuminate\Support\Facades\Auth;
trait CreatedUpdatedBy
{
public static function bootCreatedUpdatedBy()
{
// updating createdby and updatedby when model is created
static::creating(function ($model) {
if (!$model->isDirty('createdby')) {
$model->createdby = auth()->user()->id ?? 1;
}
if (!$model->isDirty('updatedby')) {
$model->updatedby = auth()->user()->id ?? 1;
}
});
// updating updatedby when model is updated
static::updating(function ($model) {
if (!$model->isDirty('updatedby')) {
$model->updatedby = auth()->user()->id ?? 1;
}
});
}
}