laravel create model from custom stub when using php artisan

后端 未结 2 1184
醉梦人生
醉梦人生 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:25

    Since Laravel 7, you can apply stub customization by running:

    php artisan stub:publish
    

    This command will publish all the stub files that are used for the artisan make commands in the stubs directory of the application root, and give you the ability to change them according to your project's needs.

    One of them is stubs/model.stub:

    Change it to:

    You can read a bit more about stub customization in this blog post.

提交回复
热议问题