ahmed-aliraqi / artisan-scaffolding
v1.0.1
2017-07-24 13:36 UTC
This package is auto-updated.
Last update: 2024-08-29 04:09:15 UTC
README
此软件包添加了一些 artisan 命令,用于生成 relations
、helpers
、scopes
、concerns
、mutators
、transformers
文件,并可以根据您的喜好覆盖 Laravel 原始的 artisan 命令。
注意:视图 artisan 命令是从 sven/artisan-view 分支的。
安装
通过 composer
composer require ahmed-aliraqi/artisan-scaffolding
或将软件包添加到 composer.json
中的依赖项,并运行 composer update
以下载软件包
{ "require": { "ahmed-aliraqi/artisan-scaffolding": "^1.0" } }
注意:如果您使用的是 Laravel 5.5,那么您就完成了!由于 自动发现,服务提供器已自动注册到容器中。
接下来,将 ServiceProvider
添加到 config/app.php
中的 providers
数组中
// config/app.php 'providers' => [ ... Aliraqi\Artisan\Scaffolding\Providers\ServiceProvider::class, ];
用法
如果您现在运行 php artisan
,您将看到 8 个新的命令
make:helper
make:mutator
make:relation
make:scope
make:concern
make:transformer
make:view
scrap:view
这些命令已被此软件包覆盖
make:model
:默认添加 fillable。make:controller
:添加生成请求选项并生成完整资源、嵌套控制器。make:policy
:添加listing
方法并将创建的策略文件名中的user
变量名替换为auther
,如果创建的策略文件名是 user。make:request
:按方法名分割规则并默认将authorize
方法的返回值更改为 true。
如果您想更改项目字符,请运行此命令以发布配置文件
php artisan vendor:publish --provider=Aliraqi\Artisan\Scaffolding\Providers\ServiceProvider --tag=config
// config/artisan-scaffolding.php
<?php
return [
/**
* the default namespace for the models classes.
*
* if you change the default namespace you need to change user model namespace in these files :-
* - config/auth.php
* - config/services.php
* - app/Http/Controllers/Auth/RegisterController.php
* - database/factories/ModelFactory.php
*
*/
'models_default_namespace' => 'App',
/**
* the default namespace for the relations traits.
*
*/
'relations_default_namespace' => 'App\Relations',
/**
* the default namespace for the concerns traits.
*
*/
'concerns_default_namespace' => 'App\Concerns',
/**
* the default namespace for the mutators traits.
*
*/
'mutators_default_namespace' => 'App\Mutators',
/**
* the default namespace for the scopes traits.
*
*/
'scopes_default_namespace' => 'App\Scopes',
/**
* the default namespace for the helpers traits.
*
*/
'helpers_default_namespace' => 'App\Helpers',
/**
* the default namespace for the policies classes.
*
*/
'policies_default_namespace' => 'App\Policies',
/**
* the default namespace for the requests classes.
*
*/
'requests_default_namespace' => 'App\Http\Requests',
/**
* the default namespace for the controllers classes.
*
*/
'controllers_default_namespace' => 'App\Http\Controllers',
/**
* the default namespace for the transformer classes.
*
*/
'transformers_default_namespace' => 'App\Transformers',
];
如果您想更改占位符文件的内容,请运行此命令
php artisan vendor:publish --provider=Aliraqi\Artisan\Scaffolding\Providers\ServiceProvider --tag=stubs
现在您可以在以下路径看到占位符文件:app\Console\stubs
许可协议
sven/artisan-view
在 MIT 许可证(MIT)下授权。有关更多信息,请参阅许可文件。