RelationNotFoundException.php 1010 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. namespace Hyperf\Database\Model;
  12. use RuntimeException;
  13. class RelationNotFoundException extends RuntimeException
  14. {
  15. /**
  16. * The name of the affected Model model.
  17. *
  18. * @var string
  19. */
  20. public $model;
  21. /**
  22. * The name of the relation.
  23. *
  24. * @var string
  25. */
  26. public $relation;
  27. /**
  28. * Create a new exception instance.
  29. *
  30. * @param string $relation
  31. * @param mixed $model
  32. * @return static
  33. */
  34. public static function make($model, $relation)
  35. {
  36. $class = get_class($model);
  37. $instance = new static("Call to undefined relationship [{$relation}] on model [{$class}].");
  38. $instance->model = $model;
  39. $instance->relation = $relation;
  40. return $instance;
  41. }
  42. }