定制 andyantunes/helper-commands 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

Latest Stable Version Total Downloads PHP Version Require License

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.php and 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

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-23