QueueEntityResolver.php 677B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace Illuminate\Database\Eloquent;
  3. use Illuminate\Contracts\Queue\EntityNotFoundException;
  4. use Illuminate\Contracts\Queue\EntityResolver as EntityResolverContract;
  5. class QueueEntityResolver implements EntityResolverContract
  6. {
  7. /**
  8. * Resolve the entity for the given ID.
  9. *
  10. * @param string $type
  11. * @param mixed $id
  12. * @return mixed
  13. *
  14. * @throws \Illuminate\Contracts\Queue\EntityNotFoundException
  15. */
  16. public function resolve($type, $id)
  17. {
  18. $instance = (new $type)->find($id);
  19. if ($instance) {
  20. return $instance;
  21. }
  22. throw new EntityNotFoundException($type, $id);
  23. }
  24. }