From a8c5aa7efdd91cf91dfb6eb9976d68138769df6a Mon Sep 17 00:00:00 2001 From: denisdulici Date: Sat, 16 Nov 2019 17:38:48 +0300 Subject: [PATCH] formatting --- app/Http/Controllers/Auth/Login.php | 2 +- app/Http/Controllers/Auth/Users.php | 2 +- app/Http/Controllers/Expenses/Bills.php | 2 +- app/Http/ViewComposers/Header.php | 4 ++-- .../Income/CreateInvoiceTransaction.php | 22 +++++++++---------- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/app/Http/Controllers/Auth/Login.php b/app/Http/Controllers/Auth/Login.php index e0028b26d..350a78518 100644 --- a/app/Http/Controllers/Auth/Login.php +++ b/app/Http/Controllers/Auth/Login.php @@ -84,7 +84,7 @@ class Login extends Controller } // Check if is customer - if ($user->contact) { + if ($user->can('read-client-portal')) { $path = session('url.intended', 'portal'); // Path must start with 'portal' prefix diff --git a/app/Http/Controllers/Auth/Users.php b/app/Http/Controllers/Auth/Users.php index afa1cd422..28d9ad549 100644 --- a/app/Http/Controllers/Auth/Users.php +++ b/app/Http/Controllers/Auth/Users.php @@ -81,7 +81,7 @@ class Users extends Controller */ public function edit(User $user) { - if ($user->contact) { + if ($user->can('read-client-portal')) { // Show only roles with customer permission $roles = Role::all()->reject(function ($r) { return !$r->hasPermission('read-client-portal'); diff --git a/app/Http/Controllers/Expenses/Bills.php b/app/Http/Controllers/Expenses/Bills.php index 2fef065d5..2755ea0cd 100644 --- a/app/Http/Controllers/Expenses/Bills.php +++ b/app/Http/Controllers/Expenses/Bills.php @@ -65,7 +65,7 @@ class Bills extends Controller $currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code')->toArray(); - $currency = Currency::where('code', $bil->currency_code)->first(); + $currency = Currency::where('code', $bill->currency_code)->first(); $account_currency_code = Account::where('id', setting('default.account'))->pluck('currency_code')->first(); diff --git a/app/Http/ViewComposers/Header.php b/app/Http/ViewComposers/Header.php index 3aef545c4..6a2e91032 100644 --- a/app/Http/ViewComposers/Header.php +++ b/app/Http/ViewComposers/Header.php @@ -27,8 +27,8 @@ class Header $company = null; // Get customer company - if ($user->contact) { - $company = (object)[ + if ($user->can('read-client-portal')) { + $company = (object) [ 'company_name' => setting('company.name'), 'company_email' => setting('company.email'), 'company_address' => setting('company.address'), diff --git a/app/Listeners/Income/CreateInvoiceTransaction.php b/app/Listeners/Income/CreateInvoiceTransaction.php index 048d6d9a8..e895d1b9f 100644 --- a/app/Listeners/Income/CreateInvoiceTransaction.php +++ b/app/Listeners/Income/CreateInvoiceTransaction.php @@ -26,21 +26,19 @@ class CreateInvoiceTransaction } catch (\Exception $e) { $message = $e->getMessage(); - $user = user(); - - if ($user) { - if ($user->contact) { - flash($message)->error(); - - redirect()->route('portal.invoices.show', $invoice->id)->send(); - } - - throw new \Exception($message); + if (!$user = user()) { + flash($message)->error(); + + redirect()->route('signed.invoices.show', $invoice->id)->send(); } - flash($message)->error(); + if ($user->can('read-client-portal')) { + flash($message)->error(); - redirect()->route('signed.invoices.show', $invoice->id)->send(); + redirect()->route('portal.invoices.show', $invoice->id)->send(); + } + + throw new \Exception($message); } } }