Kernel.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace App\Console;
  3. use App\Models\Notification;
  4. use App\Models\OrderDevice;
  5. use Carbon\Carbon;
  6. use Illuminate\Console\Scheduling\Schedule;
  7. use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
  8. class Kernel extends ConsoleKernel
  9. {
  10. /**
  11. * The Artisan commands provided by your application.
  12. *
  13. * @var array
  14. */
  15. protected $commands = [
  16. //
  17. ];
  18. /**
  19. * Define the application's command schedule.
  20. *
  21. * @param \Illuminate\Console\Scheduling\Schedule $schedule
  22. * @return void
  23. */
  24. protected function schedule(Schedule $schedule)
  25. {
  26. $schedule->call(function () {
  27. $yesterday = Carbon::yesterday()->toDateString();
  28. $order_ids = OrderDevice::where('end_date', $yesterday)->pluck('order_id')->unique();
  29. foreach($order_ids as $order_id) {
  30. Notification::send($order_id, true);
  31. }
  32. })->dailyAt('01:00');
  33. // $schedule->command('inspire')
  34. // ->hourly();
  35. }
  36. /**
  37. * Register the Closure based commands for the application.
  38. *
  39. * @return void
  40. */
  41. protected function commands()
  42. {
  43. require base_path('routes/console.php');
  44. }
  45. }