/** * Handle an incoming request. * * The following filter simply retrieves the current account based on the request information * and then sets this value for future retrieval. If no account can be found for the request, * then two things need to happen: * * 1. Check to see if ANY accounts have been configured if no accounts exist then * 2. Ask the user if they'd like to setup the default (first) account. This is required * for new installations. * 3. If an account does exist but does not match the domain, then we throw an account * not found exception and deal with that later. * * @throws AccountNotFoundException * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $account = CurrentAccount::determine($request->getHttpHost()); if (!$account) { $count = $this->accountService->totalNumberOfAccounts(); if ($count === 0) { return redirect()->route('install'); } throw new AccountNotFoundException(); } CurrentAccount::set($account); return $next($request); }
/** * Handle an incoming request. * * Check to see if ANY accounts have been setup. If they have, return a 404. This * should be used for requests that are only active when no accounts are available. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($this->accountService->totalNumberOfAccounts()) { App::abort(404); } return $next($request); }