Skip to content

Commit

Permalink
Merge pull request #58 from jeff-99/fix-tablename-generation-in-model
Browse files Browse the repository at this point in the history
fixed the check for an alternative tablename
  • Loading branch information
RichardDominik authored Feb 21, 2020
2 parents ba76bef + 04b38fb commit 809c842
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Generate/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ protected function buildClass() {
'modelBaseName' => $this->classBaseName,
'modelNameSpace' => $this->classNamespace,

// if table name differs from model name, then we need to specify the table name
'tableName' => ($this->classBaseName !== Str::studly(Str::singular($this->tableName))) ? $this->tableName : null,
// if table name differs from the snake case plural form of the classname, then we need to specify the table name
'tableName' => ($this->tableName !== Str::snake(Str::plural($this->classBaseName))) ? $this->tableName : null,

'dates' => $this->readColumnsFromTable($this->tableName)->filter(function($column) {
return $column['type'] == "datetime" || $column['type'] == "date";
Expand Down

0 comments on commit 809c842

Please sign in to comment.