diff --git a/app/Http/ViewComposers/Header.php b/app/Http/ViewComposers/Header.php index 6a2e91032..4446f9176 100644 --- a/app/Http/ViewComposers/Header.php +++ b/app/Http/ViewComposers/Header.php @@ -2,7 +2,6 @@ namespace App\Http\ViewComposers; -use Auth; use App\Utilities\Updater; use Illuminate\View\View; use App\Traits\Modules as RemoteModules; @@ -21,42 +20,43 @@ class Header { $user = user(); - $bills = []; - $invoices = []; - $notifications = 0; + $invoices = $bills = []; + $updates = $notifications = 0; $company = null; - // Get customer company - if ($user->can('read-client-portal')) { - $company = (object) [ - 'company_name' => setting('company.name'), - 'company_email' => setting('company.email'), - 'company_address' => setting('company.address'), - 'company_logo' => setting('company.logo'), - ]; - } - - $undereads = $user->unreadNotifications; - - foreach ($undereads as $underead) { - $data = $underead->getAttribute('data'); - - switch ($underead->getAttribute('type')) { - case 'App\Notifications\Expense\Bill': - $bills[$data['bill_id']] = $data['amount']; - $notifications++; - break; - case 'App\Notifications\Income\Invoice': - $invoices[$data['invoice_id']] = $data['amount']; - $notifications++; - break; + if (!empty($user)) { + // Get customer company + if ($user->can('read-client-portal')) { + $company = (object) [ + 'company_name' => setting('company.name'), + 'company_email' => setting('company.email'), + 'company_address' => setting('company.address'), + 'company_logo' => setting('company.logo'), + ]; } + + $undereads = $user->unreadNotifications; + + foreach ($undereads as $underead) { + $data = $underead->getAttribute('data'); + + switch ($underead->getAttribute('type')) { + case 'App\Notifications\Expense\Bill': + $bills[$data['bill_id']] = $data['amount']; + $notifications++; + break; + case 'App\Notifications\Income\Invoice': + $invoices[$data['invoice_id']] = $data['amount']; + $notifications++; + break; + } + } + + $updates = count(Updater::all()); + + $this->loadSuggestions(); } - $updates = count(Updater::all()); - - $this->loadSuggestions(); - $view->with([ 'user' => $user, 'notifications' => $notifications, diff --git a/app/Http/ViewComposers/Notifications.php b/app/Http/ViewComposers/Notifications.php index 1d8383894..da0d56f10 100644 --- a/app/Http/ViewComposers/Notifications.php +++ b/app/Http/ViewComposers/Notifications.php @@ -19,7 +19,7 @@ class Notifications public function compose(View $view) { // No need to add suggestions in console - if (app()->runningInConsole() || !env('APP_INSTALLED')) { + if (app()->runningInConsole() || !env('APP_INSTALLED') || !user()) { return; } diff --git a/app/Http/ViewComposers/Suggestions.php b/app/Http/ViewComposers/Suggestions.php index f665daf8e..25c568e34 100644 --- a/app/Http/ViewComposers/Suggestions.php +++ b/app/Http/ViewComposers/Suggestions.php @@ -26,26 +26,28 @@ class Suggestions $modules = false; - $path = Route::current()->uri(); + if (user()) { + $path = Route::current()->uri(); - if ($path) { - $suggestions = $this->getSuggestions($path); + if ($path) { + $suggestions = $this->getSuggestions($path); + + if ($suggestions) { + $suggestion_modules = $suggestions->modules; + + foreach ($suggestion_modules as $key => $module) { + $installed = Module::where('company_id', session('company_id'))->where('alias', $module->alias)->first(); - if ($suggestions) { - $suggestion_modules = $suggestions->modules; - - foreach ($suggestion_modules as $key => $module) { - $installed = Module::where('company_id', '=', session('company_id'))->where('alias', '=', $module->alias)->first(); - - if ($installed) { - unset($suggestion_modules[$key]); + if ($installed) { + unset($suggestion_modules[$key]); + } } - } - if ($suggestion_modules) { - shuffle($suggestion_modules); + if ($suggestion_modules) { + shuffle($suggestion_modules); - $modules[] = $suggestion_modules[0]; + $modules[] = $suggestion_modules[0]; + } } } } diff --git a/resources/lang/en-GB/errors.php b/resources/lang/en-GB/errors.php index e773681ec..c72a47530 100644 --- a/resources/lang/en-GB/errors.php +++ b/resources/lang/en-GB/errors.php @@ -2,23 +2,22 @@ return [ - 'forbidden_access' => 'Forbidden Access', - 'error_page' => 'Error Page', - 'page_not_found' => 'Page Not Found', - - 'body' => [ - 'forbidden_access' => 'Oops! Forbidden Access.', - 'error_page' => 'Oops! Something went wrong.', - 'page_not_found' => 'Oops! Page not found.', + 'title' => [ + '403' => 'Oops! Forbidden Access', + '404' => 'Oops! Page not found', + '500' => 'Oops! Something went wrong', ], - 'messages' => [ - 'forbidden_access' => 'You can not access this page. - Meanwhile, you may return to dashboard.', - 'error_page' => 'We will work on fixing that right away. - Meanwhile, you may return to dashboard.', - 'page_not_found' => 'We could not find the page you were looking for. - Meanwhile, you may return to dashboard.', + 'header' => [ + '403' => '403 Forbidden', + '404' => '404 Not Found', + '500' => '500 Internal Server Error', + ], + + 'message' => [ + '403' => 'You can not access this page.', + '404' => 'We could not find the page you were looking for.', + '500' => 'We will work on fixing that right away.', ], ]; diff --git a/resources/views/errors/403.blade.php b/resources/views/errors/403.blade.php index ff39c43ac..9632c4f06 100644 --- a/resources/views/errors/403.blade.php +++ b/resources/views/errors/403.blade.php @@ -1,16 +1,16 @@ -@extends('layouts.admin') +@extends('layouts.error') -@section('title', trans('errors.forbidden_access')) +@section('title', trans('errors.title.403')) @section('content')
{{ trans('errors.message.403') }}
-{!! trans('errors.messages.forbidden_access', ['link' => url('/') ]) !!}
+ {{ trans('general.go_to', ['name' => trans('general.dashboard')]) }}{{ trans('errors.message.404') }}
-{!! trans('errors.messages.page_not_found', ['link' => url('/')]) !!}
+ {{ trans('general.go_to', ['name' => trans('general.dashboard')]) }}{{ trans('errors.message.500') }}
-{!! trans('errors.messages.error_page', ['link' => url('/') ]) !!}
+ {{ trans('general.go_to', ['name' => trans('general.dashboard')]) }}