-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
This must be adapted if admins can create for any users
If in need to restrict data for a certain authenticated user, we can use global scopes in model in the booted() method.
EXAMPLE:
Model Tasks
(Show only tasks created by the user authenticated)
protected static function booted(): void
{
//Add a global scope for showing only the tasks created by the authenticated user
static::addGlobalScope('creator', function (Builder $builder) {
$builder->where('creator_id', Auth::id());
});
}
VIDEO 14 - Laravel 10 For REST API's
This goes perfect for: index, show, delete, update. But for store, we must modify it like:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request