Authenticated user id insert into DB laravel model with boot method
protected static function boot()
{
parent::boot();
static::creating(function ($blog) {
// Set the authenticated user's ID when a new blog is being created
if (Auth::check()) {
$blog->user_id = Auth::id();
}
});
}
No comments