first(); if(!$company){ MultiDB::findAndSetDbByAccountKey($account_or_company_key); $account = Account::where('key', $account_or_company_key)->first(); } else $account = $company->account; if (MultiDB::findAndSetDbByContactKey($contact_key) && $client_contact = ClientContact::where('contact_key', $contact_key)->first()) { nlog("Ninja Plan Controller - Found and set Client Contact"); Auth::guard('contact')->login($client_contact,true); /* Current paid users get pushed straight to subscription overview page*/ if($account->isPaidHostedClient()) return redirect('/client/subscriptions'); /* Users that are not paid get pushed to a custom purchase page */ return $this->render('subscriptions.ninja_plan', ['settings' => $client_contact->company->settings]); } return redirect()->route('client.catchall'); } }