invoiceRepo = $invoiceRepo; $this->datatableService = $datatableService; } public function getDatatable($accountId, $clientPublicId, $entityType, $search) { $datatable = new RecurringInvoiceDatatable(true, $clientPublicId); $query = $this->invoiceRepo->getRecurringInvoices($accountId, $clientPublicId, $search); if (! Utils::hasPermission('view_recurring_invoice')) { $query->where('invoices.user_id', '=', Auth::user()->id); } return $this->datatableService->createDatatable($datatable, $query); } }