PHP code example of andyantunes / helper-commands

1. Go to this page and download the library: Download andyantunes/helper-commands library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

andyantunes / helper-commands example snippets


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();
}

User::withoutEvents(function () {
    $this->command->warn(PHP_EOL . 'Creating users...');

    $this->withProgressBar(7, fn () => User::factory(1)->create());

    $this->command->info('Users created.');
});
bash
php artisan vendor:publish --provider="AndyAntunes\\HelperCommands\\HelperCommandsServiceProvider"
bash
php artisan migrate
bash
php artisan helper:activity
bash
php artisan helper:factory