public static function bootTenantableTrait()
 {
     static::addGlobalScope(new TenantScope());
     static::creating(function (Model $model) {
         $model->account_id = Account::getCurrent()->id;
     });
 }
Example #2
0
 public function apply(Builder $builder, Model $model)
 {
     $account = Account::getCurrent();
     if (isset($account)) {
         $builder->whereHas('account', function ($query) use($account) {
             $query->where('accounts.id', $account->id);
         });
     }
 }