DeliveryAppointmentCheck.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App\Jobs;
  3. use App\DeliveryAppointment;
  4. use Carbon\Carbon;
  5. use Illuminate\Bus\Queueable;
  6. use Illuminate\Contracts\Queue\ShouldQueue;
  7. use Illuminate\Foundation\Bus\Dispatchable;
  8. use Illuminate\Queue\InteractsWithQueue;
  9. use Illuminate\Queue\SerializesModels;
  10. class DeliveryAppointmentCheck implements ShouldQueue
  11. {
  12. use Dispatchable, InteractsWithQueue, Queueable;
  13. protected $int;
  14. /**
  15. * Create a new job instance.
  16. *
  17. * @param int $int
  18. *
  19. * @return void
  20. */
  21. public function __construct(int $int)
  22. {
  23. $this->int = $int;
  24. }
  25. /**
  26. * Execute the job.
  27. *
  28. * @return void
  29. */
  30. public function handle()
  31. {
  32. /** @var DeliveryAppointment|\stdClass $appointment */
  33. $appointment = DeliveryAppointment::query()->find($this->int);
  34. $time = explode("-",DeliveryAppointment::PERIOD[$appointment->date_period])[1];
  35. if ($appointment && $appointment->status==0
  36. && Carbon::now()->gt(Carbon::parse($appointment->appointment_date." ".$time.":00:00"))
  37. )$appointment->update(["status"=>3]);
  38. }
  39. }