public function dashboard($contactKey = false)
{
if ($contactKey) {
if (!($contact = Contact::where('contact_key', '=', $contactKey)->first())) {
return $this->returnError();
}
Session::put('contact_key', $contactKey);
// track current contact
} else {
if (!($contact = $this->getContact())) {
return $this->returnError();
}
}
$client = $contact->client;
$account = $client->account;
$account->loadLocalizationSettings($client);
$color = $account->primary_color ? $account->primary_color : '#0b4d78';
$customer = false;
if (!$account->enable_client_portal) {
return $this->returnError();
} elseif (!$account->enable_client_portal_dashboard) {
return redirect()->to('/client/invoices/');
}
if ($paymentDriver = $account->paymentDriver(false, GATEWAY_TYPE_TOKEN)) {
$customer = $paymentDriver->customer($client->id);
}
$data = ['color' => $color, 'contact' => $contact, 'account' => $account, 'client' => $client, 'clientFontUrl' => $account->getFontsUrl(), 'gateway' => $account->getTokenGateway(), 'paymentMethods' => $customer ? $customer->payment_methods : false, 'transactionToken' => $paymentDriver ? $paymentDriver->createTransactionToken() : false];
return response()->view('invited.dashboard', $data);
}