src/Mpociot/Teamwork/Traits/UsedByTeams.php
protected static function bootUsedByTeams()
    {
        static::addGlobalScope('team', function (Builder $builder) {
            static::teamGuard();

            $builder->where($builder->getQuery()->from . '.team_id', auth()->user()->currentTeam->getKey());
        });

        static::saving(function (Model $model) {
            static::teamGuard();

            if (!isset($model->team_id)) {
                $model->team_id = auth()->user()->currentTeam->getKey();
            }
        });
    }
protected static function bootUsedByTeams()
    {
        static::addGlobalScope('team', function (Builder $builder) {
            static::teamGuard();

            $builder->where($builder->getQuery()->from . '.team_id', auth()->user()->currentTeam->getKey());
        });

        static::saving(function (Model $model) {
            static::teamGuard();

            if (!isset($model->team_id)) {
                $model->team_id = auth()->user()->currentTeam->getKey();
            }
        });
    }
protected static function bootUsedByTeams ( ) { static :: addGlobalScope ( 'team' , function ( Builder $ builder ) { static :: teamGuard ( ) ; $ builder -> where ( $ builder -> getQuery ( ) -> from . '.team_id' , auth ( ) -> user ( ) -> currentTeam -> getKey ( ) ) ; } ) ; static :: saving ( function ( Model $ model ) { static :: teamGuard ( ) ; if ( ! isset ( $ model -> team_id ) ) { $ model -> team_id = auth ( ) -> user ( ) -> currentTeam -> getKey ( ) ; } } ) ; }
Boot the global scope
Boot the global scope