render('recurring_invoices.index'); } /** * Display the recurring invoice. * * @param ShowRecurringInvoiceRequest $request * @param RecurringInvoice $recurring_invoice * * @return Factory|View */ public function show(ShowRecurringInvoiceRequest $request, RecurringInvoice $recurring_invoice) { return $this->render('recurring_invoices.show', [ 'invoice' => $recurring_invoice->load('invoices'), ]); } /** * Handle the request cancellation notification * * @param RequestCancellationRequest $request [description] * @param RecurringInvoice $recurring_invoice [description] * * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View */ public function requestCancellation(RequestCancellationRequest $request, RecurringInvoice $recurring_invoice) { if ($recurring_invoice->subscription?->allow_cancellation) { $nmo = new NinjaMailerObject(); $nmo->mailable = (new NinjaMailer((new ClientContactRequestCancellationObject($recurring_invoice, auth()->user(), false))->build())); $nmo->company = $recurring_invoice->company; $nmo->settings = $recurring_invoice->company->settings; $recurring_invoice->company->company_users->each(function ($company_user) use ($nmo) { $methods = $this->findCompanyUserNotificationType($company_user, ['recurring_cancellation', 'all_notifications']); //if mail is a method type -fire mail!! if (($key = array_search('mail', $methods)) !== false) { unset($methods[$key]); $nmo->to_user = $company_user->user; NinjaMailerJob::dispatch($nmo); } }); return $this->render('recurring_invoices.cancellation.index', [ 'invoice' => $recurring_invoice, ]); } return back(); } }