LaborApplyRecordJob.php 959 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App\Jobs;
  3. use App\Exceptions\WarningException;
  4. use App\Services\LaborApplyService;
  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 LaborApplyRecordJob implements ShouldQueue
  11. {
  12. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  13. /** @var $service LaborApplyService */
  14. private $service;
  15. /**
  16. * Create a new job instance.
  17. *
  18. * @return void
  19. */
  20. public function __construct()
  21. {
  22. $this->service = app('LaborApplyService');
  23. }
  24. /**
  25. * Execute the job.
  26. * @return void
  27. * @throws WarningException
  28. */
  29. public function handle()
  30. {
  31. $response = $this->service->allocationLaborToLaborCompany();
  32. if (!$response['success']) throw new WarningException($response['error_message']);
  33. }
  34. }