-
app/Scopes/UserVisibilityScope.php
Open in GitHubuse Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Scope; use Illuminate\Support\Facades\Auth; final class UserVisibilityScope implements Scope { public function apply(Builder $builder, Model $model) { $builder->where('user_id', Auth::id()); } }
-
app/Models/Category.php
Open in GitHubuse App\Scopes\UserVisibilityScope; use Illuminate\Database\Eloquent\Model; final class Category extends Model { // protected static function booted(): void { static::addGlobalScope(new UserVisibilityScope()); } // }