| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- declare(strict_types=1);
- /**
- * This file is part of Hyperf.
- *
- * @link https://www.hyperf.io
- * @document https://hyperf.wiki
- * @contact group@hyperf.io
- * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
- */
- namespace Hyperf\Database\Model;
- use Hyperf\Collection\Arr;
- use RuntimeException;
- class ModelNotFoundException extends RuntimeException
- {
- /**
- * Name of the affected Model model.
- */
- protected ?string $model = null;
- /**
- * The affected model IDs.
- */
- protected array $ids = [];
- /**
- * Set the affected Model model and instance ids.
- *
- * @param array|int|string $ids
- * @return $this
- */
- public function setModel(string $model, $ids = [])
- {
- $this->model = $model;
- $this->ids = Arr::wrap($ids);
- $this->message = "No query results for model [{$model}]";
- if (count($this->ids) > 0) {
- $this->message .= ' ' . implode(', ', $this->ids);
- } else {
- $this->message .= '.';
- }
- return $this;
- }
- /**
- * Get the affected Model model.
- */
- public function getModel(): ?string
- {
- return $this->model;
- }
- /**
- * Get the affected Model model IDs.
- */
- public function getIds(): array
- {
- return $this->ids;
- }
- }
|