Give feedback when a relation can't be resolved (#1052)

Improves https://github.com/barryvdh/laravel-ide-helper/pull/1017 slightly
This commit is contained in:
Markus Podar
2020-09-10 21:58:16 +02:00
committed by GitHub
parent 2a3c7fb087
commit 5db6029f2c
2 changed files with 12 additions and 2 deletions
+5 -2
View File
@@ -38,6 +38,7 @@ use ReflectionObject;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Throwable;
/**
* A command to generate autocomplete information for your IDE
@@ -277,7 +278,7 @@ class ModelsCommand extends Command
$output .= $this->createPhpDocs($name);
$ignore[] = $name;
$this->nullableColumns = [];
} catch (\Throwable $e) {
} catch (Throwable $e) {
$this->error('Exception: ' . $e->getMessage() .
"\nCould not analyze class $name.\n\nTrace:\n" .
$e->getTraceAsString());
@@ -601,7 +602,9 @@ class ModelsCommand extends Command
$relationObj = Relation::noConstraints(function () use ($model, $method) {
try {
return $model->$method();
} catch (\Throwable $e) {
} catch (Throwable $e) {
$this->warn(sprintf('Error resolving relation model of %s:%s() : %s', get_class($model), $method, $e->getMessage()));
return null;
}
});