2019-07-19 06:32:51 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-07-19 06:32:51 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2020-01-07 01:13:47 +01:00
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-07-19 06:32:51 +02:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\ViewComposers;
|
|
|
|
|
2020-05-09 00:19:39 +02:00
|
|
|
use App\Models\ClientContact;
|
2020-11-10 04:36:16 +01:00
|
|
|
use App\Utils\Ninja;
|
2019-08-12 00:33:17 +02:00
|
|
|
use App\Utils\TranslationHelper;
|
2020-11-10 04:36:16 +01:00
|
|
|
use Illuminate\Support\Facades\Lang;
|
2019-07-19 06:32:51 +02:00
|
|
|
use Illuminate\View\View;
|
|
|
|
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Class PortalComposer.
|
2019-07-19 06:32:51 +02:00
|
|
|
*/
|
|
|
|
class PortalComposer
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Bind data to the view.
|
|
|
|
*
|
|
|
|
* @param View $view
|
|
|
|
* @return void
|
|
|
|
*/
|
2019-07-22 05:54:34 +02:00
|
|
|
public function compose(View $view) :void
|
2019-07-19 06:32:51 +02:00
|
|
|
{
|
2019-12-30 22:59:12 +01:00
|
|
|
$view->with($this->portalData());
|
2020-11-10 04:36:16 +01:00
|
|
|
|
2020-11-25 11:30:00 +01:00
|
|
|
if (auth()->user()) {
|
2020-11-10 04:36:16 +01:00
|
|
|
Lang::replace(Ninja::transformTranslations(auth()->user()->client->getMergedSettings()));
|
2020-11-25 11:30:00 +01:00
|
|
|
}
|
2019-07-19 06:32:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2019-07-22 05:54:34 +02:00
|
|
|
private function portalData() :array
|
2019-07-19 06:32:51 +02:00
|
|
|
{
|
2020-09-06 11:38:10 +02:00
|
|
|
if (! auth()->user()) {
|
2019-07-19 06:32:51 +02:00
|
|
|
return [];
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
2019-07-19 06:32:51 +02:00
|
|
|
|
2019-07-22 05:54:34 +02:00
|
|
|
$data['sidebar'] = $this->sidebarMenu();
|
|
|
|
$data['header'] = [];
|
|
|
|
$data['footer'] = [];
|
2019-08-12 00:33:17 +02:00
|
|
|
$data['countries'] = TranslationHelper::getCountries();
|
2019-08-21 06:29:07 +02:00
|
|
|
$data['company'] = auth()->user()->company;
|
|
|
|
$data['client'] = auth()->user()->client;
|
2019-11-04 01:22:59 +01:00
|
|
|
$data['settings'] = auth()->user()->client->getMergedSettings();
|
2020-06-09 14:42:23 +02:00
|
|
|
$data['currencies'] = TranslationHelper::getCurrencies();
|
2020-05-27 06:46:19 +02:00
|
|
|
|
|
|
|
$data['multiple_contacts'] = ClientContact::where('email', auth('contact')->user()->email)->whereNotNull('email')->distinct('company_id')->get();
|
2019-11-04 01:22:59 +01:00
|
|
|
|
2019-07-19 06:32:51 +02:00
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
2019-07-22 05:54:34 +02:00
|
|
|
private function sidebarMenu() :array
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
|
2020-06-26 16:05:48 +02:00
|
|
|
// $data[] = [ 'title' => ctrans('texts.dashboard'), 'url' => 'client.dashboard', 'icon' => 'activity'];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data[] = ['title' => ctrans('texts.invoices'), 'url' => 'client.invoices.index', 'icon' => 'file-text'];
|
|
|
|
$data[] = ['title' => ctrans('texts.recurring_invoices'), 'url' => 'client.recurring_invoices.index', 'icon' => 'file'];
|
|
|
|
$data[] = ['title' => ctrans('texts.payments'), 'url' => 'client.payments.index', 'icon' => 'credit-card'];
|
|
|
|
$data[] = ['title' => ctrans('texts.quotes'), 'url' => 'client.quotes.index', 'icon' => 'align-left'];
|
|
|
|
$data[] = ['title' => ctrans('texts.credits'), 'url' => 'client.credits.index', 'icon' => 'credit-card'];
|
|
|
|
$data[] = ['title' => ctrans('texts.payment_methods'), 'url' => 'client.payment_methods.index', 'icon' => 'shield'];
|
2020-09-28 12:04:34 +02:00
|
|
|
$data[] = ['title' => ctrans('texts.documents'), 'url' => 'client.documents.index', 'icon' => 'download'];
|
2019-07-22 05:54:34 +02:00
|
|
|
|
2020-11-17 15:01:28 +01:00
|
|
|
if (auth()->user('contact')->client->getSetting('enable_client_portal_tasks')) {
|
2020-11-25 11:30:00 +01:00
|
|
|
$data[] = ['title' => ctrans('texts.tasks'), 'url' => 'client.dashboard', 'icon' => 'clock'];
|
2020-11-17 15:01:28 +01:00
|
|
|
|
|
|
|
// TODO: Update when 'tasks' module is available in client portal.
|
|
|
|
}
|
|
|
|
|
2019-07-22 05:54:34 +02:00
|
|
|
return $data;
|
|
|
|
}
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|