Casts
1 month ago
Concerns
1 month ago
Factories
1 month ago
Relations
1 month ago
BroadcastableModelEventOccurred.php
1 month ago
BroadcastsEvents.php
6 months ago
Builder.php
1 month ago
Collection.php
1 month ago
HigherOrderBuilderProxy.php
2 years ago
InvalidCastException.php
2 years ago
JsonEncodingException.php
2 years ago
MassAssignmentException.php
2 years ago
MassPrunable.php
6 months ago
MissingAttributeException.php
1 month ago
Model.php
1 month ago
ModelNotFoundException.php
1 month ago
PendingHasThroughRelationship.php
1 month ago
Prunable.php
2 years ago
QueueEntityResolver.php
2 years ago
RelationNotFoundException.php
2 years ago
Scope.php
2 years ago
SoftDeletes.php
1 month ago
SoftDeletingScope.php
1 month ago
ModelNotFoundException.php
63 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWPSCOPED\Illuminate\Database\Eloquent; |
| 4 | |
| 5 | use IAWPSCOPED\Illuminate\Database\RecordsNotFoundException; |
| 6 | use IAWPSCOPED\Illuminate\Support\Arr; |
| 7 | /** |
| 8 | * @template TModel of \Illuminate\Database\Eloquent\Model |
| 9 | * @internal |
| 10 | */ |
| 11 | class ModelNotFoundException extends RecordsNotFoundException |
| 12 | { |
| 13 | /** |
| 14 | * Name of the affected Eloquent model. |
| 15 | * |
| 16 | * @var class-string<TModel> |
| 17 | */ |
| 18 | protected $model; |
| 19 | /** |
| 20 | * The affected model IDs. |
| 21 | * |
| 22 | * @var array<int, int|string> |
| 23 | */ |
| 24 | protected $ids; |
| 25 | /** |
| 26 | * Set the affected Eloquent model and instance ids. |
| 27 | * |
| 28 | * @param class-string<TModel> $model |
| 29 | * @param array<int, int|string>|int|string $ids |
| 30 | * @return $this |
| 31 | */ |
| 32 | public function setModel($model, $ids = []) |
| 33 | { |
| 34 | $this->model = $model; |
| 35 | $this->ids = Arr::wrap($ids); |
| 36 | $this->message = "No query results for model [{$model}]"; |
| 37 | if (\count($this->ids) > 0) { |
| 38 | $this->message .= ' ' . \implode(', ', $this->ids); |
| 39 | } else { |
| 40 | $this->message .= '.'; |
| 41 | } |
| 42 | return $this; |
| 43 | } |
| 44 | /** |
| 45 | * Get the affected Eloquent model. |
| 46 | * |
| 47 | * @return class-string<TModel> |
| 48 | */ |
| 49 | public function getModel() |
| 50 | { |
| 51 | return $this->model; |
| 52 | } |
| 53 | /** |
| 54 | * Get the affected Eloquent model IDs. |
| 55 | * |
| 56 | * @return array<int, int|string> |
| 57 | */ |
| 58 | public function getIds() |
| 59 | { |
| 60 | return $this->ids; |
| 61 | } |
| 62 | } |
| 63 |