DispatchesJobs.php 752 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: yunzhong
  5. * Date: 2019/7/30
  6. * Time: 15:23
  7. */
  8. namespace app\Jobs;
  9. use app\common\facades\Setting;
  10. use Illuminate\Contracts\Bus\Dispatcher;
  11. class DispatchesJobs
  12. {
  13. const LOW = 'low';
  14. public static function dispatch($job, $queue)
  15. {
  16. $is_open = Setting::getNotUniacid('supervisor.queue.is_classify');
  17. if ($is_open) {
  18. $job->queue = $queue;
  19. }
  20. return app(Dispatcher::class)->dispatch($job);
  21. }
  22. /**
  23. * Dispatch a command to its appropriate handler in the current process.
  24. *
  25. * @param mixed $job
  26. * @return mixed
  27. */
  28. public function dispatchNow($job)
  29. {
  30. return app(Dispatcher::class)->dispatchNow($job);
  31. }
  32. }