Skip to content

Instantly share code, notes, and snippets.

@gbrits
Last active May 10, 2022 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbrits/36eb27bae5b2684674c2af7ec781a211 to your computer and use it in GitHub Desktop.
Save gbrits/36eb27bae5b2684674c2af7ec781a211 to your computer and use it in GitHub Desktop.
Laravel Cheat Sheet
// Restricting a model's scope, for tenancy
protected static function boot()
{
parent::boot();
self::addGlobalScope(function(Builder $builder) {
$builder->where('team_id', auth()->user()->current_team_id);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment