From 1c96b358bfaaa5fd4b98565b7c53dfbc8e29887f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Tue, 29 Jun 2021 11:47:38 +0200 Subject: [PATCH] Show tasks based on setting in the client portal --- app/Http/Livewire/TasksTable.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/Http/Livewire/TasksTable.php b/app/Http/Livewire/TasksTable.php index 9298b1b183b3..f477af99b5bd 100644 --- a/app/Http/Livewire/TasksTable.php +++ b/app/Http/Livewire/TasksTable.php @@ -26,17 +26,26 @@ class TasksTable extends Component public $per_page = 10; public $company; - + public function mount() { MultiDB::setDb($this->company->db); } - + public function render() { $query = Task::query() - ->where('client_id', auth('contact')->user()->client->id) - ->whereNotNull('invoice_id') + ->where('client_id', auth('contact')->user()->client->id); + + if ($this->company->getSetting('show_all_tasks_client_portal') === 'invoiced') { + $query = $query->whereNotNull('invoice_id'); + } + + if ($this->company->getSetting('show_all_tasks_client_portal') === 'uninvoiced') { + $query = $query->whereNull('invoice_id'); + } + + $query = $query ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc') ->paginate($this->per_page);