RelationNotFoundException.php 792B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace Illuminate\Database\Eloquent;
  3. use RuntimeException;
  4. class RelationNotFoundException 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 mixed $model
  22. * @param string $relation
  23. * @return static
  24. */
  25. public static function make($model, $relation)
  26. {
  27. $class = get_class($model);
  28. $instance = new static("Call to undefined relationship [{$relation}] on model [{$class}].");
  29. $instance->model = $model;
  30. $instance->relation = $relation;
  31. return $instance;
  32. }
  33. }