ModelIdentifier.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace Illuminate\Contracts\Database;
  3. class ModelIdentifier
  4. {
  5. /**
  6. * The class name of the model.
  7. *
  8. * @var class-string<\Illuminate\Database\Eloquent\Model>
  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 class-string<\Illuminate\Database\Eloquent\Collection>|null
  35. */
  36. public $collectionClass;
  37. /**
  38. * Create a new model identifier.
  39. *
  40. * @param class-string<\Illuminate\Database\Eloquent\Model> $class
  41. * @param mixed $id
  42. * @param array $relations
  43. * @param mixed $connection
  44. */
  45. public function __construct($class, $id, array $relations, $connection)
  46. {
  47. $this->id = $id;
  48. $this->class = $class;
  49. $this->relations = $relations;
  50. $this->connection = $connection;
  51. }
  52. /**
  53. * Specify the collection class that should be used when serializing / restoring collections.
  54. *
  55. * @param class-string<\Illuminate\Database\Eloquent\Collection> $collectionClass
  56. * @return $this
  57. */
  58. public function useCollectionClass(?string $collectionClass)
  59. {
  60. $this->collectionClass = $collectionClass;
  61. return $this;
  62. }
  63. }