Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the rest of the parameters for the model #34

Open
ezkorpyo opened this issue Mar 21, 2017 · 1 comment
Open

Add the rest of the parameters for the model #34

ezkorpyo opened this issue Mar 21, 2017 · 1 comment

Comments

@ezkorpyo
Copy link

ezkorpyo commented Mar 21, 2017

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
Copy link
Author

ezkorpyo commented Mar 23, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants