RelationNotFoundException.php 1001 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 object $model
  22. * @param string $relation
  23. * @param string|null $type
  24. * @return static
  25. */
  26. public static function make($model, $relation, $type = null)
  27. {
  28. $class = get_class($model);
  29. $instance = new static(
  30. is_null($type)
  31. ? "Call to undefined relationship [{$relation}] on model [{$class}]."
  32. : "Call to undefined relationship [{$relation}] on model [{$class}] of type [{$type}].",
  33. );
  34. $instance->model = $class;
  35. $instance->relation = $relation;
  36. return $instance;
  37. }
  38. }