işte anlamayınca da birleştiremiyorsun..static boot lu methodu model dosyama koydum..
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Profile extends Model
{
protected $table="prosystem_administrator";
public static function boot()
{
parent::boot();
static::creating(function($post)
{
$post->created_by = Auth::user()->id;
$post->updated_by = Auth::user()->id;
});
static::updating(function($post)
{
$post->updated_by = Auth::user()->id;
});
}
}
herhangi bir controller dosyasında da
$model=\App\Models\Profile::where("id","=",1)->update(['created_at'=>time()]);
$model::updating(function($model)
{
foreach($model->getDirty() as $attribute => $value){
$original= $model->getOriginal($attribute);
return "Changed $attribute from '$original' to '$value'<br/>\r\n";
}
return true; //if false the model wont save!
});
bunu calıstırınca
Class name must be a valid object or a string
verdiği hata bu