lumen-generators
lumen-generators copied to clipboard
Add the rest of the parameters for the model
The rest of the parameters, for the reason of a better personalization for already existing structures, which are required to map to LUMEN.
Add:
- protected $table
- protected $primaryKey
- public $incrementing
Change:
- The first letter to upper case
In wn/lumen-generators/src/Commands/ModelCommand.php, I modified the following:
In "$signature" var I add:
{--table= : Name of the table.}
{--primary-key= : Name of the primary key.}
{--incrementing= : Incrementing field.}
In "handle" function I modified: $name = $this->argument('name'); To $name = ucfirst($this->argument('name'));
In "getAdditional" function I modified:
protected function getAdditional()
{
$additional = '';
$additional = (!empty($this->option('table')))
? ' protected $table = \''.$this->option('table').'\';' . PHP_EOL . PHP_EOL
: '';
$additional .= (!empty($this->option('primary-key')))
? ' protected $primaryKey = \''.$this->option('primary-key').'\';' . PHP_EOL . PHP_EOL
: '';
$additional .= ($this->option('incrementing') == 'false')
? ' public $incrementing = false;' . PHP_EOL . PHP_EOL
: '';
$additional .= ($this->option('timestamps') == 'false')
? ' public $timestamps = false;' . PHP_EOL . PHP_EOL
: '';
return $additional;
}
I do not know if this is the best way to do it, but it worked.