andyantunes/helper-commands
最新稳定版本:v2.0.4
Composer 安装命令:
composer require andyantunes/helper-commands
包简介
Helper to automate the creation of observers to Models
README 文档
README
Commands to help in the development of laravel projects
Table of Contents
Installation
Install the package via composer
composer require andyantunes/helper-commands --dev
Publish the migration to use the Log Activities and the config/helper-commands.php config file
php artisan vendor:publish --provider="AndyAntunes\\HelperCommands\\HelperCommandsServiceProvider"
Before running migration
- Check the configuration file
config/helper-commands.phpand change the configurations if you need
Run the migration
php artisan migrate
Activity Log
To generate the classes and methods use this command
php artisan helper:activity
and select the Model which you use to generate the Observer.
Observer
The observer class is generated with the following methods
public function created(MyModel $myModel): void { $action = "Criou o myModel de ID: {$myModel->id}"; LogActivity::setAction($action) ->create(); }
public function updated(MyModel $myModel): void { $action = "Atualizou o myModel de ID: {$myModel->id}"; LogActivity::setAction($action) ->create(); }
public function deleted(MyModel $myModel): void { $action = "Deletou o myModel de ID: {$myModel->id}"; LogActivity::setAction($action) ->create(); }
public function restored(MyModel $myModel): void { $action = "Restaurou o myModel de ID: {$myModel->id}"; LogActivity::setAction($action) ->create(); }
public function forceDeleted(MyModel $myModel): void { $action = "Removeu o myModel de ID: {$myModel->id}"; LogActivity::setAction($action) ->create(); }
Factories
To generate factories based in your table use this command
php artisan helper:factory
and select options like ModelName, quantity of records and whether to have events withEvents
Example of the created Factory
User::withoutEvents(function () { $this->command->warn(PHP_EOL . 'Creating users...'); $this->withProgressBar(7, fn () => User::factory(1)->create()); $this->command->info('Users created.'); });
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 99
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-08-23