diff --git a/app/Http/Livewire/CreditsTable.php b/app/Http/Livewire/CreditsTable.php index 12e29cbb0102..b347e6486c6e 100644 --- a/app/Http/Livewire/CreditsTable.php +++ b/app/Http/Livewire/CreditsTable.php @@ -35,7 +35,7 @@ class CreditsTable extends Component public function render() { $query = Credit::query() - ->where('client_id', auth()->guard('contact')->user()->client->id) + ->where('client_id', auth()->guard('contact')->user()->client_id) ->where('company_id', $this->company->id) ->where('status_id', '<>', Credit::STATUS_DRAFT) ->where('is_deleted', 0) diff --git a/app/Http/Livewire/InvoicesTable.php b/app/Http/Livewire/InvoicesTable.php index e8bd125e506f..bfb6a47f5109 100644 --- a/app/Http/Livewire/InvoicesTable.php +++ b/app/Http/Livewire/InvoicesTable.php @@ -43,10 +43,10 @@ class InvoicesTable extends Component $local_status = []; $query = Invoice::query() - ->with('client.gateway_tokens', 'client.contacts') - ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc') ->where('company_id', $this->company->id) - ->where('is_deleted', false); + ->where('is_deleted', false) + ->with('client.gateway_tokens', 'client.contacts') + ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc'); if (in_array('paid', $this->status)) { $local_status[] = Invoice::STATUS_PAID; @@ -76,8 +76,7 @@ class InvoicesTable extends Component $query = $query ->where('client_id', auth()->guard('contact')->user()->client_id) - ->where('status_id', '<>', Invoice::STATUS_DRAFT) - ->where('status_id', '<>', Invoice::STATUS_CANCELLED) + ->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL, Invoice::STATUS_PAID, Invoice::STATUS_REVERSED]) ->withTrashed() ->paginate($this->per_page); diff --git a/app/Http/Livewire/PaymentsTable.php b/app/Http/Livewire/PaymentsTable.php index c46bc7f7271f..716efb78724d 100644 --- a/app/Http/Livewire/PaymentsTable.php +++ b/app/Http/Livewire/PaymentsTable.php @@ -40,9 +40,9 @@ class PaymentsTable extends Component { $query = Payment::query() ->with('type', 'client') - ->whereIn('status_id', [Payment::STATUS_FAILED, Payment::STATUS_COMPLETED, Payment::STATUS_PENDING, Payment::STATUS_REFUNDED, Payment::STATUS_PARTIALLY_REFUNDED]) ->where('company_id', $this->company->id) - ->where('client_id', auth()->guard('contact')->user()->client->id) + ->where('client_id', auth()->guard('contact')->user()->client_id) + ->whereIn('status_id', [Payment::STATUS_FAILED, Payment::STATUS_COMPLETED, Payment::STATUS_PENDING, Payment::STATUS_REFUNDED, Payment::STATUS_PARTIALLY_REFUNDED]) ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc') ->withTrashed() ->paginate($this->per_page); diff --git a/app/Http/Livewire/PurchaseOrdersTable.php b/app/Http/Livewire/PurchaseOrdersTable.php index 5b1c1087d729..d4b629986025 100644 --- a/app/Http/Livewire/PurchaseOrdersTable.php +++ b/app/Http/Livewire/PurchaseOrdersTable.php @@ -45,10 +45,10 @@ class PurchaseOrdersTable extends Component $query = PurchaseOrder::query() ->with('vendor.contacts') - ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc') - ->whereIn('status_id', [PurchaseOrder::STATUS_SENT, PurchaseOrder::STATUS_ACCEPTED]) ->where('company_id', $this->company->id) - ->where('is_deleted', false); + ->whereIn('status_id', [PurchaseOrder::STATUS_SENT, PurchaseOrder::STATUS_ACCEPTED]) + ->where('is_deleted', false) + ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc'); if (in_array('sent', $this->status)) { $local_status[] = PurchaseOrder::STATUS_SENT; diff --git a/app/Http/Livewire/QuotesTable.php b/app/Http/Livewire/QuotesTable.php index 4600a0f7a9d9..93f416703968 100644 --- a/app/Http/Livewire/QuotesTable.php +++ b/app/Http/Livewire/QuotesTable.php @@ -79,9 +79,9 @@ class QuotesTable extends Component $query = $query ->where('company_id', $this->company->id) - ->where('client_id', auth()->guard('contact')->user()->client->id) - ->where('status_id', '<>', Quote::STATUS_DRAFT) + ->where('client_id', auth()->guard('contact')->user()->client_id) ->where('is_deleted', 0) + ->where('status_id', '<>', Quote::STATUS_DRAFT) ->withTrashed() ->paginate($this->per_page); diff --git a/app/Http/Livewire/RecurringInvoicesTable.php b/app/Http/Livewire/RecurringInvoicesTable.php index 28be1c3690ad..7f0e573a6e7e 100644 --- a/app/Http/Livewire/RecurringInvoicesTable.php +++ b/app/Http/Livewire/RecurringInvoicesTable.php @@ -40,7 +40,7 @@ class RecurringInvoicesTable extends Component $query = RecurringInvoice::query(); $query = $query - ->where('client_id', auth()->guard('contact')->user()->client->id) + ->where('client_id', auth()->guard('contact')->user()->client_id) ->where('company_id', $this->company->id) ->whereIn('status_id', [RecurringInvoice::STATUS_ACTIVE]) ->orderBy('status_id', 'asc') diff --git a/app/Http/Livewire/TasksTable.php b/app/Http/Livewire/TasksTable.php index 8bba0cb22515..6a9fce6cd77d 100644 --- a/app/Http/Livewire/TasksTable.php +++ b/app/Http/Livewire/TasksTable.php @@ -37,7 +37,7 @@ class TasksTable extends Component $query = Task::query() ->where('company_id', $this->company->id) ->where('is_deleted', false) - ->where('client_id', auth()->guard('contact')->user()->client->id); + ->where('client_id', auth()->guard('contact')->user()->client_id); if ($this->company->getSetting('show_all_tasks_client_portal') === 'invoiced') { $query = $query->whereNotNull('invoice_id');