Last active
May 10, 2022 08:21
-
-
Save gbrits/36eb27bae5b2684674c2af7ec781a211 to your computer and use it in GitHub Desktop.
Laravel Cheat Sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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