db); $this->company = Company::find($this->company_id); } public function render() { $query = Credit::query() ->where('company_id', $this->company->id) ->where('client_id', auth()->guard('contact')->user()->client_id) ->where('status_id', '<>', Credit::STATUS_DRAFT) ->where('is_deleted', 0) ->where(function ($query) { $query->whereDate('due_date', '>=', now()) ->orWhereNull('due_date'); }) ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc') ->withTrashed() ->paginate($this->per_page); return render('components.livewire.credits-table', [ 'credits' => $query, ]); } }