lumen-generators icon indicating copy to clipboard operation
lumen-generators copied to clipboard

Add the rest of the parameters for the model

Open ezkorpyo opened this issue 7 years ago • 1 comments

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

ezkorpyo avatar Mar 21 '17 23:03 ezkorpyo

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.

ezkorpyo avatar Mar 23 '17 17:03 ezkorpyo