| @@ 92-95 (lines=4) @@ | ||
| 89 | public static function firstOrFail($query = []) |
|
| 90 | { |
|
| 91 | $model = static::first($query); |
|
| 92 | if (is_null($model)) { |
|
| 93 | $reflect = new ReflectionClass(get_called_class()); |
|
| 94 | throw new ModelNotFoundException(sprintf('Model `%s` not found', $reflect->getShortName())); |
|
| 95 | } |
|
| 96 | return $model; |
|
| 97 | } |
|
| 98 | ||
| @@ 212-217 (lines=6) @@ | ||
| 209 | public static function findOrFail($id, array $columns = ['*'], $parentId = null) |
|
| 210 | { |
|
| 211 | $model = static::find($id, $columns, ['parent_id' => $parentId]); |
|
| 212 | if (is_null($model)) { |
|
| 213 | $reflect = new ReflectionClass(get_called_class()); |
|
| 214 | throw new ModelNotFoundException(sprintf( |
|
| 215 | 'Model `%s` not found by id `%s`', $reflect->getShortName(), $id |
|
| 216 | )); |
|
| 217 | } |
|
| 218 | return $model; |
|
| 219 | } |
|
| 220 | ||