ModelIdentifier.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace Illuminate\Contracts\Database;
  3. class ModelIdentifier
  4. {
  5. /**
  6. * The class name of the model.
  7. *
  8. * @var string
  9. */
  10. public $class;
  11. /**
  12. * The unique identifier of the model.
  13. *
  14. * This may be either a single ID or an array of IDs.
  15. *
  16. * @var mixed
  17. */
  18. public $id;
  19. /**
  20. * The relationships loaded on the model.
  21. *
  22. * @var array
  23. */
  24. public $relations;
  25. /**
  26. * The connection name of the model.
  27. *
  28. * @var string|null
  29. */
  30. public $connection;
  31. /**
  32. * The class name of the model collection.
  33. *
  34. * @var string|null
  35. */
  36. public $collectionClass;
  37. /**
  38. * Create a new model identifier.
  39. *
  40. * @param string $class
  41. * @param mixed $id
  42. * @param array $relations
  43. * @param mixed $connection
  44. * @return void
  45. */
  46. public function __construct($class, $id, array $relations, $connection)
  47. {
  48. $this->id = $id;
  49. $this->class = $class;
  50. $this->relations = $relations;
  51. $this->connection = $connection;
  52. }
  53. /**
  54. * Specify the collection class that should be used when serializing / restoring collections.
  55. *
  56. * @param string|null $collectionClass
  57. * @return $this
  58. */
  59. public function useCollectionClass(?string $collectionClass)
  60. {
  61. $this->collectionClass = $collectionClass;
  62. return $this;
  63. }
  64. }