Add disable write magic methods on models (#466)

* Add desable write magic methods on models

* Fix property name

* Opps commit

* Fix

* Change default parameter of property
This commit is contained in:
Ivan Boldyrev
2017-03-16 11:46:50 +01:00
committed by Barry vd. Heuvel
parent b611cb5eff
commit 144a50e8ee
2 changed files with 20 additions and 5 deletions
+11
View File
@@ -25,6 +25,17 @@ return array(
'include_fluent' => false, 'include_fluent' => false,
/*
|--------------------------------------------------------------------------
| Write Model Magic methods
|--------------------------------------------------------------------------
|
| Set to false to disable write magic methods of model
|
*/
'write_model_magic_where' => true,
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Helper files to include | Helper files to include
+9 -5
View File
@@ -50,6 +50,7 @@ class ModelsCommand extends Command
*/ */
protected $description = 'Generate autocompletion for models'; protected $description = 'Generate autocompletion for models';
protected $write_model_magic_where;
protected $properties = array(); protected $properties = array();
protected $methods = array(); protected $methods = array();
protected $write = false; protected $write = false;
@@ -81,6 +82,7 @@ class ModelsCommand extends Command
$model = $this->argument('model'); $model = $this->argument('model');
$ignore = $this->option('ignore'); $ignore = $this->option('ignore');
$this->reset = $this->option('reset'); $this->reset = $this->option('reset');
$this->write_model_magic_where = $this->laravel['config']->get('ide-helper.write_model_magic_where', true);
//If filename is default and Write is not specified, ask what to do //If filename is default and Write is not specified, ask what to do
if (!$this->write && $filename === $this->filename && !$this->option('nowrite')) { if (!$this->write && $filename === $this->filename && !$this->option('nowrite')) {
@@ -362,11 +364,13 @@ class ModelsCommand extends Command
$comment = $column->getComment(); $comment = $column->getComment();
$this->setProperty($name, $type, true, true, $comment); $this->setProperty($name, $type, true, true, $comment);
$this->setMethod( if ($this->write_model_magic_where) {
Str::camel("where_" . $name), $this->setMethod(
'\Illuminate\Database\Query\Builder|\\' . get_class($model), Str::camel("where_" . $name),
array('$value') '\Illuminate\Database\Query\Builder|\\' . get_class($model),
); array('$value')
);
}
} }
} }
} }