webHookOverdueInvoices(); $this->webHookExpiredQuotes(); } private function webHookOverdueInvoices() { $invoices = Invoice::where('is_deleted', 0) ->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) ->where('balance', '>', 0) ->whereDate('due_date', now()->subDays(1)->startOfDay()) ->cursor(); $invoices->each(function ($invoice){ WebHookHandler::dispatch(Webhook::EVENT_LATE_INVOICE, $invoice); }); } private function webHookExpiredQuotes() { $quotes = Quote::where('is_deleted', 0) ->where('status_id', Quote::STATUS_SENT) ->whereDate('due_date', now()->subDays(1)->startOfDay()) ->cursor(); $quotes->each(function ($quote){ WebHookHandler::dispatch(Webhook::EVENT_EXPIRED_QUOTE, $quote); }); } }