App\Ninja\Repositories\InvoiceRepository::getRecurringInvoices PHP Method

getRecurringInvoices() public method

public getRecurringInvoices ( $accountId, $clientPublicId = false, $filter = false )
    public function getRecurringInvoices($accountId, $clientPublicId = false, $filter = false)
    {
        $query = DB::table('invoices')->join('accounts', 'accounts.id', '=', 'invoices.account_id')->join('clients', 'clients.id', '=', 'invoices.client_id')->join('frequencies', 'frequencies.id', '=', 'invoices.frequency_id')->join('contacts', 'contacts.client_id', '=', 'clients.id')->where('invoices.account_id', '=', $accountId)->where('invoices.invoice_type_id', '=', INVOICE_TYPE_STANDARD)->where('contacts.deleted_at', '=', null)->where('invoices.is_recurring', '=', true)->where('contacts.is_primary', '=', true)->where('clients.deleted_at', '=', null)->select(DB::raw('COALESCE(clients.currency_id, accounts.currency_id) currency_id'), DB::raw('COALESCE(clients.country_id, accounts.country_id) country_id'), 'clients.public_id as client_public_id', DB::raw("COALESCE(NULLIF(clients.name,''), NULLIF(CONCAT(contacts.first_name, ' ', contacts.last_name),''), NULLIF(contacts.email,'')) client_name"), 'invoices.public_id', 'invoices.amount', 'frequencies.name as frequency', 'invoices.start_date', 'invoices.end_date', 'contacts.first_name', 'contacts.last_name', 'contacts.email', 'invoices.deleted_at', 'invoices.is_deleted', 'invoices.user_id');
        if ($clientPublicId) {
            $query->where('clients.public_id', '=', $clientPublicId);
        }
        if (!\Session::get('show_trash:recurring_invoice')) {
            $query->where('invoices.deleted_at', '=', null);
        }
        if ($filter) {
            $query->where(function ($query) use($filter) {
                $query->where('clients.name', 'like', '%' . $filter . '%')->orWhere('invoices.invoice_number', 'like', '%' . $filter . '%');
            });
        }
        return $query;
    }