Undefined variable in Structure\Table
Closed this issue · 1 comments
superkozel commented
Hello, there is minor error here:
public function getColumns()
{
$cols = $this->table->getColumns();
$columns = []; <--missing
foreach ($cols as $key => $col) {
$columns[] = new Column($col);
}
return $columns;
}
and also minor error here:
try {
// handle abstract classes, interfaces, ...
$reflectionClass = new \ReflectionClass($model_name);
if (!$reflectionClass->isSubclassOf('Illuminate\Database\Eloquent\Model')) {
print_r("\nNot an eloquent '$model_name' class");
return false;
}
if (!$reflectionClass->IsInstantiable()) {
// ignore abstract class or interface
return false;
}
$model = $this->app->make($model_name);
$this->model = new Model($model);
$finder = new RelationFinder();
if ($recursive) {
$this->model->relations = $finder->getModelRelations($model_name);
}
} catch (\Exception $e) {
print_r('Exception: ' . $e->getMessage() . "\nCould not analyze class {$this->model->name}."); <---HERE
}
this print_r fails if exception happens before $this->model declaration and all you get is "getting property name of undefined variable"
Thanks a lot, great utility, just what i looked for
victoryoalli commented
Thanks for your help. Fixed it using $model_name.