From 144a50e8ee020d9185e4480ffb4e5fec03832324 Mon Sep 17 00:00:00 2001 From: Ivan Boldyrev Date: Thu, 16 Mar 2017 12:46:50 +0200 Subject: [PATCH] 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 --- config/ide-helper.php | 11 +++++++++++ src/Console/ModelsCommand.php | 14 +++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/config/ide-helper.php b/config/ide-helper.php index 5350f3a..f481d4c 100644 --- a/config/ide-helper.php +++ b/config/ide-helper.php @@ -25,6 +25,17 @@ return array( '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 diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 240b5ca..6794c69 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -50,6 +50,7 @@ class ModelsCommand extends Command */ protected $description = 'Generate autocompletion for models'; + protected $write_model_magic_where; protected $properties = array(); protected $methods = array(); protected $write = false; @@ -81,6 +82,7 @@ class ModelsCommand extends Command $model = $this->argument('model'); $ignore = $this->option('ignore'); $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 (!$this->write && $filename === $this->filename && !$this->option('nowrite')) { @@ -362,11 +364,13 @@ class ModelsCommand extends Command $comment = $column->getComment(); $this->setProperty($name, $type, true, true, $comment); - $this->setMethod( - Str::camel("where_" . $name), - '\Illuminate\Database\Query\Builder|\\' . get_class($model), - array('$value') - ); + if ($this->write_model_magic_where) { + $this->setMethod( + Str::camel("where_" . $name), + '\Illuminate\Database\Query\Builder|\\' . get_class($model), + array('$value') + ); + } } } }