mirror of
https://github.com/danog/psalm-plugin-laravel.git
synced 2024-11-30 04:39:01 +01:00
Fix getModels
This commit is contained in:
parent
406eda6bf4
commit
084742d798
@ -17,8 +17,11 @@ use Barryvdh\Reflection\DocBlock\Serializer as DocBlockSerializer;
|
||||
|
||||
class FakeModelsCommand extends \Barryvdh\LaravelIdeHelper\Console\ModelsCommand
|
||||
{
|
||||
/** @var SchemaAggregator */
|
||||
private $schema;
|
||||
/** @var SchemaAggregator */
|
||||
private $schema;
|
||||
|
||||
/** @var array<class-string> */
|
||||
private $model_classes = [];
|
||||
|
||||
/**
|
||||
* @param Filesystem $files
|
||||
@ -29,6 +32,12 @@ class FakeModelsCommand extends \Barryvdh\LaravelIdeHelper\Console\ModelsCommand
|
||||
$this->schema = $schema;
|
||||
}
|
||||
|
||||
/** @return array<class-string> */
|
||||
public function getModels()
|
||||
{
|
||||
return $this->model_classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the properties from the database table.
|
||||
*
|
||||
@ -39,9 +48,11 @@ class FakeModelsCommand extends \Barryvdh\LaravelIdeHelper\Console\ModelsCommand
|
||||
$table_name = $model->getTable();
|
||||
|
||||
if (!isset($this->schema->tables[$table_name])) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
$this->model_classes[] = get_class($model);
|
||||
|
||||
$columns = $this->schema->tables[$table_name]->columns;
|
||||
|
||||
foreach ($columns as $column) {
|
||||
@ -71,11 +82,11 @@ class FakeModelsCommand extends \Barryvdh\LaravelIdeHelper\Console\ModelsCommand
|
||||
break;
|
||||
|
||||
case 'enum':
|
||||
if (!$column->options) {
|
||||
$type = 'string';
|
||||
} else {
|
||||
$type = '\'' . implode('\'|\'', $column->options) . '\'';
|
||||
}
|
||||
if (!$column->options) {
|
||||
$type = 'string';
|
||||
} else {
|
||||
$type = '\'' . implode('\'|\'', $column->options) . '\'';
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@ -91,7 +102,7 @@ class FakeModelsCommand extends \Barryvdh\LaravelIdeHelper\Console\ModelsCommand
|
||||
|
||||
$this->setProperty($name, $type, true, true, '', $column->nullable);
|
||||
if ($this->write_model_magic_where) {
|
||||
$this->setMethod(
|
||||
$this->setMethod(
|
||||
Str::camel("where_" . $name),
|
||||
'\Illuminate\Database\Eloquent\Builder|\\' . get_class($model),
|
||||
array('$value')
|
||||
@ -105,6 +116,6 @@ class FakeModelsCommand extends \Barryvdh\LaravelIdeHelper\Console\ModelsCommand
|
||||
*/
|
||||
protected function getPropertiesFromMethods($model) : void
|
||||
{
|
||||
// do nothing here
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user