LazyLoadingViolationException.php 771 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace Illuminate\Database;
  3. use RuntimeException;
  4. class LazyLoadingViolationException extends RuntimeException
  5. {
  6. /**
  7. * The name of the affected Eloquent model.
  8. *
  9. * @var string
  10. */
  11. public $model;
  12. /**
  13. * The name of the relation.
  14. *
  15. * @var string
  16. */
  17. public $relation;
  18. /**
  19. * Create a new exception instance.
  20. *
  21. * @param object $model
  22. * @param string $relation
  23. * @return static
  24. */
  25. public function __construct($model, $relation)
  26. {
  27. $class = get_class($model);
  28. parent::__construct("Attempted to lazy load [{$relation}] on model [{$class}] but lazy loading is disabled.");
  29. $this->model = $class;
  30. $this->relation = $relation;
  31. }
  32. }