From c344af9de33509f321bc2492a85ead90b4370692 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 5 Mar 2018 16:40:10 +0200 Subject: [PATCH] PHP 7.2 fixes --- app/Http/Controllers/InvoiceController.php | 2 +- app/Http/Controllers/QuoteController.php | 2 +- app/Models/EntityModel.php | 12 ++++++------ resources/views/invoices/edit.blade.php | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index c084851d8b70..cfde36f324f7 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -327,7 +327,7 @@ class InvoiceController extends BaseController 'invoiceLabels' => Auth::user()->account->getInvoiceLabels(), 'tasks' => Session::get('tasks') ? Session::get('tasks') : null, 'expenseCurrencyId' => Session::get('expenseCurrencyId') ?: null, - 'expenses' => Session::get('expenses') ? Expense::scope(Session::get('expenses'))->with('documents', 'expense_category')->get() : [], + 'expenses' => Expense::scope(Session::get('expenses'))->with('documents', 'expense_category')->get(), ]; } diff --git a/app/Http/Controllers/QuoteController.php b/app/Http/Controllers/QuoteController.php index 06b363297d2f..601c243f9ea1 100644 --- a/app/Http/Controllers/QuoteController.php +++ b/app/Http/Controllers/QuoteController.php @@ -108,7 +108,7 @@ class QuoteController extends BaseController 'invoiceFonts' => Cache::get('fonts'), 'invoiceLabels' => Auth::user()->account->getInvoiceLabels(), 'isRecurring' => false, - 'expenses' => [], + 'expenses' => collect(), ]; } diff --git a/app/Models/EntityModel.php b/app/Models/EntityModel.php index d922d641e7ad..fb02f1404983 100644 --- a/app/Models/EntityModel.php +++ b/app/Models/EntityModel.php @@ -155,18 +155,18 @@ class EntityModel extends Eloquent */ public function scopeScope($query, $publicId = false, $accountId = false) { - if (! $accountId) { - $accountId = Auth::user()->account_id; - } - - $query->where($this->getTable() .'.account_id', '=', $accountId); - // If 'false' is passed as the publicId return nothing rather than everything if (func_num_args() > 1 && ! $publicId && ! $accountId) { $query->where('id', '=', 0); return $query; } + if (! $accountId) { + $accountId = Auth::user()->account_id; + } + + $query->where($this->getTable() .'.account_id', '=', $accountId); + if ($publicId) { if (is_array($publicId)) { $query->whereIn('public_id', $publicId); diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index fbaa3d94f705..6417703865bf 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -470,7 +470,7 @@ - @if ($invoice->hasExpenseDocuments() || count($expenses)) + @if ($invoice->hasExpenseDocuments() || $expenses->count())

{{trans('texts.documents_from_expenses')}}

@foreach($invoice->expenses as $expense) @if ($expense->invoice_documents)