diff --git a/Modules/Taxi/App/Console/SendOrdersToTaxiCommand.php b/Modules/Taxi/App/Console/SendOrdersToTaxiCommand.php new file mode 100644 index 0000000..072024a --- /dev/null +++ b/Modules/Taxi/App/Console/SendOrdersToTaxiCommand.php @@ -0,0 +1,90 @@ +executeCommand(function () { + $todayOrders = TaxiMain::where('cancel_rqst', 0) + ->where('taxi_date', (new DateTime())->format('Y-m-d')) + ->get() + ->toArray(); + + if (!$todayOrders) { + Mail::send(new Mailer( + new BaseMailerObj( + + ) + )); + echo '
'; var_dump('da'); echo'
'; + } else { + echo '
'; var_dump('net'); echo'
'; + } + + throw new Error('Ошипка!'); + }, 'еще инва'); + + // try { + // throw new Error('Ошипка!'); + // } catch (\Throwable $th) { + // \Log::channel('schedule_err')->error($th->getFile() . ": " . $th->getMessage() . " Line: " . $th->getLine()); + // } + + //$this->info('Daily report generated at ' . now()); + + return 0; + } + + /** + * Get the console command arguments. + */ + protected function getArguments(): array + { + return [ + ['example', InputArgument::REQUIRED, 'An example argument.'], + ]; + } + + /** + * Get the console command options. + */ + protected function getOptions(): array + { + return [ + ['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null], + ]; + } +} diff --git a/Modules/Taxi/App/Jobs/TaxiMailJob.php b/Modules/Taxi/App/Jobs/TaxiMailJob.php new file mode 100644 index 0000000..a91a9ca --- /dev/null +++ b/Modules/Taxi/App/Jobs/TaxiMailJob.php @@ -0,0 +1,40 @@ +jobData + )); + } +} diff --git a/Modules/Taxi/App/Mail/BaseTaxiMail.php b/Modules/Taxi/App/Mail/BaseTaxiMail.php new file mode 100644 index 0000000..d3a2c43 --- /dev/null +++ b/Modules/Taxi/App/Mail/BaseTaxiMail.php @@ -0,0 +1,32 @@ +orderData->emp_login], + "Создана заявка на такси", + "Для вас создана заявка на такси № {$this->orderId}: + ", + config('taxi.name_ru'), + ); + } +} diff --git a/Modules/Taxi/App/Providers/TaxiMailerProvider.php b/Modules/Taxi/App/Providers/TaxiMailerProvider.php new file mode 100644 index 0000000..1337f75 --- /dev/null +++ b/Modules/Taxi/App/Providers/TaxiMailerProvider.php @@ -0,0 +1,28 @@ +app->bind(TaxiMailerService::class, function ($app) { + return new TaxiMailerService(); + }); + } + + /** + * Get the services provided by the provider. + */ + public function provides(): array + { + return []; + } +} diff --git a/Modules/Taxi/App/Providers/TaxiScheduleProvider.php b/Modules/Taxi/App/Providers/TaxiScheduleProvider.php new file mode 100644 index 0000000..1eaf999 --- /dev/null +++ b/Modules/Taxi/App/Providers/TaxiScheduleProvider.php @@ -0,0 +1,31 @@ +app->runningInConsole()) { + $this->commands([ + SendOrdersToTaxiCommand::class, // ✅ Теперь Laravel знает о команде + ]); + } + } + + /** + * Get the services provided by the provider. + */ + public function provides(): array + { + return []; + } +} diff --git a/Modules/Taxi/App/Services/TaxiMailerService.php b/Modules/Taxi/App/Services/TaxiMailerService.php new file mode 100644 index 0000000..0ad96f3 --- /dev/null +++ b/Modules/Taxi/App/Services/TaxiMailerService.php @@ -0,0 +1,27 @@ +prepareDataForMail())->onQueue('emails')->delay(5); + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php new file mode 100644 index 0000000..0ae4c30 --- /dev/null +++ b/app/Console/Kernel.php @@ -0,0 +1,40 @@ +command('inspire')->hourly(); + //activity()->log('Look mum, I logged something'); + #Гаврилов + //ПРОВЕРИТЬ, РАБОТАЕТ? + // $schedule->command('sanctum:prune-expired --hours=24') + // ->daily(); + //->dailyAt('21:03'); + // activity() + // ->byAnonymous() + // ->inLog('Shedule') + // ->event('clear_old_Sanctum_tokens'); + + //попытка поработать с командами по расписанию. Не успел протестить. В частности, в этом скрипте планируется в определенное время инициировать отправку всех заявок на такси + $schedule->command('taxi:send-today-orders-mail')->dailyAt('08:00'); + } + + /** + * Register the commands for the application. + */ + protected function commands(): void + { + $this->load(__DIR__ . '/Commands'); + + require base_path('routes/console.php'); + } +}