|
12 | 12 | use RonasIT\Support\DTO\RelationsDTO; |
13 | 13 | use RonasIT\Support\Events\WarningEvent; |
14 | 14 | use Illuminate\Database\Eloquent\Relations\BelongsTo; |
15 | | -use RonasIT\Support\Exceptions\ClassNotExistsException; |
| 15 | +use RonasIT\Support\Exceptions\ResourceNotExistsException; |
16 | 16 | use RonasIT\Support\Exceptions\IncorrectClassPathException; |
17 | 17 | use RonasIT\Support\Exceptions\ResourceAlreadyExistsException; |
18 | 18 |
|
@@ -214,11 +214,7 @@ protected function getRelatedModels(string $model, string $creatableClass): arra |
214 | 214 | $modelClass = $this->getModelClass($model); |
215 | 215 |
|
216 | 216 | if (!class_exists($modelClass)) { |
217 | | - $this->throwFailureException( |
218 | | - exceptionClass: ClassNotExistsException::class, |
219 | | - failureMessage: "Cannot create {$creatableClass} cause {$model} Model does not exists.", |
220 | | - recommendedMessage: "Create a {$model} Model by himself or run command 'php artisan make:entity {$model} --only-model'.", |
221 | | - ); |
| 217 | + throw new ResourceNotExistsException($creatableClass, $model); |
222 | 218 | } |
223 | 219 |
|
224 | 220 | $instance = new $modelClass(); |
@@ -329,6 +325,15 @@ protected function checkResourceExists(string $path, string $resourceName, ?stri |
329 | 325 | } |
330 | 326 | } |
331 | 327 |
|
| 328 | + protected function checkResourceNotExists(string $path, string $createableResource, string $requiredResource, ?string $subFolder = null): void |
| 329 | + { |
| 330 | + if (!$this->classExists($path, $requiredResource, $subFolder)) { |
| 331 | + $filePath = $this->getClassPath($path, $requiredResource, $subFolder); |
| 332 | + |
| 333 | + throw new ResourceNotExistsException($createableResource, $filePath); |
| 334 | + } |
| 335 | + } |
| 336 | + |
332 | 337 | protected function getRelationName(string $relation, string $type): string |
333 | 338 | { |
334 | 339 | $relationName = Str::snake($relation); |
|
0 commit comments