Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
peripherad
/
app
/
Console
/
Commands
:
SendOrderPaymentReminderCommand.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace App\Console\Commands; use App\Models\Order; use App\Models\OrderPaymentReminder; use App\Models\SiteSetting; use App\Notifications\OrderPaymentReminderNotification; use Illuminate\Console\Command; use Illuminate\Support\Facades\Log; class SendOrderPaymentReminderCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'email:send-order-payment-reminder'; /** * The console command description. * * @var string */ protected $description = 'Send email every three days to users who have not paid there order.'; public function handle(): void { $orders = OrderPaymentReminder::all(); $approve_url = config('app.react_app_payment_url'); $company_phone_1 = SiteSetting::where('key', 'Site Phone')->first(); $company_phone_2 = SiteSetting::where('key', 'Site Phone 2')->first(); $contact_email = SiteSetting::where('key', 'Notification Email')->first(); $location = SiteSetting::where('key', 'Location')->first(); foreach ($orders as $key => $order) { $db_order = Order::find($order->order_id); $pj_invoice = generatePJInvoice($db_order); if ($order->payment_status !== "Paid") { $data = [ 'user' => $order->user, 'order_number' => $order->order_number, 'amount' => $order->grand_total, 'payment_url' => $approve_url . $order->order_id, 'invoice_url' => $pj_invoice->hostedInvoiceUrl ?? null, 'order_total' => "$" . $order->grand_total, 'company_phone_1' => $company_phone_1->value ?? "N/A", 'company_phone_2' => $company_phone_2->value ?? "N/A", 'contact_email' => $contact_email->value ?? "N/A", 'location' => $location->value ?? "N/A", 'invoice_path' => $db_order->invoice->invoicePath ?? '', ]; Log::channel('info_errors')->info("Payment Reminder Email. Invoice path for order id $order->id is " . ($db_order->invoice->invoicePath ?? '')); $order->user->notify((new OrderPaymentReminderNotification($data))->delay(now()->addSeconds($key))); Log::channel('cron_jobs') ->info('Order payment reminder mail sent successfully to order id : ' . $order->order_id . ' at ' . now()->format('m-d-Y h:i:s')); } } } }