Make writing relation count properties optional (#969)

* Make writing relation count properties optional

* Clean up description

* Add test for write_model_magic_where=false

* Add test for write_model_relation_count_properties=false
This commit is contained in:
Luka Schäfer
2020-06-23 22:27:43 +02:00
committed by GitHub
parent 6ec4f7baf9
commit cca99b6d25
6 changed files with 426 additions and 6 deletions
+11 -6
View File
@@ -57,6 +57,7 @@ class ModelsCommand extends Command
protected $description = 'Generate autocompletion for models';
protected $write_model_magic_where;
protected $write_model_relation_count_properties;
protected $properties = array();
protected $methods = array();
protected $write = false;
@@ -107,6 +108,8 @@ class ModelsCommand extends Command
$this->keep_text = $this->reset = true;
}
$this->write_model_magic_where = $this->laravel['config']->get('ide-helper.write_model_magic_where', true);
$this->write_model_relation_count_properties =
$this->laravel['config']->get('ide-helper.write_model_relation_count_properties', true);
//If filename is default and Write is not specified, ask what to do
if (!$this->write && $filename === $this->filename && !$this->option('nowrite')) {
@@ -587,12 +590,14 @@ class ModelsCommand extends Command
true,
null
);
$this->setProperty(
Str::snake($method) . '_count',
'int|null',
true,
false
);
if ($this->write_model_relation_count_properties) {
$this->setProperty(
Str::snake($method) . '_count',
'int|null',
true,
false
);
}
} elseif ($relation === "morphTo") {
// Model isn't specified because relation is polymorphic
$this->setProperty(