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

command make model wrong dir #96

Closed
socheth opened this issue Oct 29, 2020 · 1 comment
Closed

command make model wrong dir #96

socheth opened this issue Oct 29, 2020 · 1 comment

Comments

@socheth
Copy link

socheth commented Oct 29, 2020

On Lumen 8, I have use command make model, but it generate file outside model directory.
It should be generate file in Models directory.

@stsonline
Copy link

I was working on a Lumen 5.8 project and wanted to move the models for consistency with an associated Laravel project.
I discovered that you can set this yourself, as follows:

In app/Providers/AppServiceProvider.php add this at the top

use App\Console\Commands\ModelMakeCommand;

and inside the class add the following in the register method:

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->extend('command.model.make', function ($command, $app) {
            return new ModelMakeCommand($app['files']);
        });
    }

In app/Console/Commands create a new class ModelMakeCommand.php with the following content:

<?php

namespace App\Console\Commands;

use Flipbox\LumenGenerator\Console\ModelMakeCommand as Command;

class ModelMakeCommand extends Command
{
    /**
     * Get the default namespace for the class.
     *
     * @param  string  $rootNamespace
     * @return string
     */
    protected function getDefaultNamespace($rootNamespace)
    {
        return "{$rootNamespace}\Models";
    }
}

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

No branches or pull requests

3 participants