with(['company_user' => function ($query){ return $query->whereNull('company_user.deleted_at'); }]) ->where('account_id', 1) ->distinct() ->select('users.id') ->count(); return $count < auth()->user()->company()->account->num_users; //return auth()->user()->company()->account->users->count() < auth()->user()->company()->account->num_users; } /** * @return string */ public function message() { return ctrans('texts.limit_users', ['limit' => auth()->user()->company()->account->num_users]); } }