DatabaseJobRecord.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace Illuminate\Queue\Jobs;
  3. use Illuminate\Support\InteractsWithTime;
  4. class DatabaseJobRecord
  5. {
  6. use InteractsWithTime;
  7. /**
  8. * The underlying job record.
  9. *
  10. * @var \stdClass
  11. */
  12. protected $record;
  13. /**
  14. * Create a new job record instance.
  15. *
  16. * @param \stdClass $record
  17. * @return void
  18. */
  19. public function __construct($record)
  20. {
  21. $this->record = $record;
  22. }
  23. /**
  24. * Increment the number of times the job has been attempted.
  25. *
  26. * @return int
  27. */
  28. public function increment()
  29. {
  30. $this->record->attempts++;
  31. return $this->record->attempts;
  32. }
  33. /**
  34. * Update the "reserved at" timestamp of the job.
  35. *
  36. * @return int
  37. */
  38. public function touch()
  39. {
  40. $this->record->reserved_at = $this->currentTime();
  41. return $this->record->reserved_at;
  42. }
  43. /**
  44. * Dynamically access the underlying job information.
  45. *
  46. * @param string $key
  47. * @return mixed
  48. */
  49. public function __get($key)
  50. {
  51. return $this->record->{$key};
  52. }
  53. }