From cae70babc54d59f2e59b0de562f4bcd7540d7d6f Mon Sep 17 00:00:00 2001 From: Ignas Bernotas Date: Sat, 11 Mar 2017 14:13:36 +0000 Subject: [PATCH] fixed older laravel version incompatibility --- src/Commands/MakeModelsCommand.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Commands/MakeModelsCommand.php b/src/Commands/MakeModelsCommand.php index 3750b43..73619fb 100644 --- a/src/Commands/MakeModelsCommand.php +++ b/src/Commands/MakeModelsCommand.php @@ -187,11 +187,15 @@ protected function generateTable($table) // replace table prefix $tablePrefix = $this->option('prefix') ?: \DB::getTablePrefix(); - $prefixRemovedTableName = str_replace($tablePrefix,'',$table); + $prefixRemovedTableName = str_replace($tablePrefix, '', $table); $class = VariableConversion::convertTableNameToClassName($prefixRemovedTableName); - - $name = Pluralizer::singular($this->qualifyClass($prefix . $class)); + + if (method_exists($this, 'qualifyClass')) { + $name = Pluralizer::singular($this->qualifyClass($prefix . $class)); + } else { + $name = Pluralizer::singular($this->parseName($prefix . $class)); + } if ($this->files->exists($path = $this->getPath($name)) && !$this->option('force')) { return $this->error($this->extends . ' for ' . $table . ' already exists!'); @@ -413,7 +417,7 @@ protected function getOptions() { return [ ['tables', null, InputOption::VALUE_OPTIONAL, 'Comma separated table names to generate', null], - ['prefix',null, InputOption::VALUE_OPTIONAL, 'Table prefix',null], + ['prefix', null, InputOption::VALUE_OPTIONAL, 'Table prefix', null], ['dir', null, InputOption::VALUE_OPTIONAL, 'Model directory', $this->namespace], ['extends', null, InputOption::VALUE_OPTIONAL, 'Parent class', $this->extends], ['fillable', null, InputOption::VALUE_OPTIONAL, 'Rules for $fillable array columns', $this->fillableRules],