laravel create model from custom stub when using php artisan

后端 未结 2 1171
醉梦人生
醉梦人生 2021-02-20 06:04

When I use php artisan make:model CustomNamespace\\TestModel, I get a model based on default stub as this :

namespace App\\Models\\CustomNamespace;
         


        
2条回答
  •  走了就别回头了
    2021-02-20 06:38

    Create a new command, extend the Illuminate\Foundation\Console\ModelMakeCommand class and override the getStub() method:

    protected function getStub()
    {
        if ($this->option('pivot')) {
            return __DIR__.'/stubs/pivot.model.stub';
        }
    
        return storage_path('/stubs/my-own-model.stub');
    }
    

提交回复
热议问题