public function show(ClientRequest $request)
{
$client = $request->entity();
$user = Auth::user();
$actionLinks = [];
if ($user->can('create', ENTITY_TASK)) {
$actionLinks[] = ['label' => trans('texts.new_task'), 'url' => URL::to('/tasks/create/' . $client->public_id)];
}
if (Utils::hasFeature(FEATURE_QUOTES) && $user->can('create', ENTITY_QUOTE)) {
$actionLinks[] = ['label' => trans('texts.new_quote'), 'url' => URL::to('/quotes/create/' . $client->public_id)];
}
if (!empty($actionLinks)) {
$actionLinks[] = \DropdownButton::DIVIDER;
}
if ($user->can('create', ENTITY_PAYMENT)) {
$actionLinks[] = ['label' => trans('texts.enter_payment'), 'url' => URL::to('/payments/create/' . $client->public_id)];
}
if ($user->can('create', ENTITY_CREDIT)) {
$actionLinks[] = ['label' => trans('texts.enter_credit'), 'url' => URL::to('/credits/create/' . $client->public_id)];
}
if ($user->can('create', ENTITY_EXPENSE)) {
$actionLinks[] = ['label' => trans('texts.enter_expense'), 'url' => URL::to('/expenses/create/0/' . $client->public_id)];
}
$token = $client->getGatewayToken();
$data = ['actionLinks' => $actionLinks, 'showBreadcrumbs' => false, 'client' => $client, 'credit' => $client->getTotalCredit(), 'title' => trans('texts.view_client'), 'hasRecurringInvoices' => Invoice::scope()->where('is_recurring', '=', true)->whereClientId($client->id)->count() > 0, 'hasQuotes' => Invoice::scope()->invoiceType(INVOICE_TYPE_QUOTE)->whereClientId($client->id)->count() > 0, 'hasTasks' => Task::scope()->whereClientId($client->id)->count() > 0, 'gatewayLink' => $token ? $token->gatewayLink() : false, 'gatewayName' => $token ? $token->gatewayName() : false];
return View::make('clients.show', $data);
}