Edit File: NotifyForScheduledOrder.php
<?php namespace App\Console\Commands; use App\Enums\OrderStatus; use App\Enums\OrderStatusEnum; use App\Enums\OrderType; use App\Enums\OrderWhenEnum; use App\Models\Order; use App\Notifications\OrderNotification; use App\Notifications\OrderStatusNotification; use Carbon\Carbon; use Illuminate\Console\Command; use Illuminate\Support\Facades\Notification; class NotifyForScheduledOrder extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'scheduled-order:notify'; /** * The console command description. * * @var string */ protected $description = 'Notify for scheduled order'; /** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); } /** * Execute the console command. * * @return int */ public function handle() { $orders = Order::whereType(OrderWhenEnum::SCHEDULE->value) ->whereIn('status', [OrderStatusEnum::Accepted->value]) ->get(); foreach ($orders as $order) { if (Carbon::createFromFormat('Y-m-d H:i:s', $order?->schedule_execution_date . ' ' . $order?->schedule_execution_time) > Carbon::now()->subHours(3)) { Notification::send([$order->provider], new OrderNotification($order, 'notify_new_schedule')); } } } }
Back to File Manager