Skip to content

Commit

Permalink
Merge pull request #33 from TheDragonCode/2.x
Browse files Browse the repository at this point in the history
Added the `artisan` method
  • Loading branch information
Andrey Helldar authored Dec 24, 2021
2 parents 8d8c163 + e8b16c8 commit e0314bc
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 6 deletions.
34 changes: 28 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ Or manually update `require` block of `composer.json` and run `composer update`.
```json
{
"require": {
"dragon-code/laravel-migration-actions": "^2.2"
"dragon-code/laravel-migration-actions": "^2.3"
}
}
```

### Upgrade from `dragon-code/laravel-actions`
### Upgrade From `dragon-code/laravel-actions`

1. In your `composer.json` file, replace `dragon-code/laravel-actions` with `dragon-code/laravel-migration-actions`.
3. Run the `command composer` update.
4. Profit!

### Upgrade from `andrey-helldar/laravel-migration-actions`
### Upgrade From `andrey-helldar/laravel-migration-actions`

1. In your `composer.json` file, replace `"andrey-helldar/laravel-actions": "^1.0"` with `"dragon-code/laravel-migration-actions": "^2.0"`.
2. Replace the `Helldar\LaravelActions` namespace prefix with `DragonCode\LaravelActions` in your app;
Expand Down Expand Up @@ -63,9 +63,9 @@ the `Register Service Providers` section of your `bootstrap/app.php`.
$app->register(\DragonCode\LaravelActions\ServiceProvider::class);
```

## How to use
## How To Use

### Generating actions
### Creating Actions

To create a migration, use the `make:migration:action` Artisan command:

Expand Down Expand Up @@ -274,7 +274,7 @@ The `migrate:actions:status` command displays the execution status of actions. I
php artisan migrate:actions:status
```

### Execution status
### Execution Status

You can also override the `success` and `failed` methods, which are called on success or failure processing.

Expand Down Expand Up @@ -347,7 +347,29 @@ Call the `php artisan migrate:actions` command.

The log file will contain two `failed` entries.

### Artisan Command

Quite often, when working with actions, it becomes necessary to run one or another console command, and each time you have to write the following code:

```php
use Illuminate\Support\Facades\Artisan;

public function up()
{
Artisan::call('command-name');
}
```

Since version [`2.3`](https://github.com/TheDragonCode/laravel-migration-actions/releases/tag/v2.3.0) we have added a method call. Now calling commands has become much easier:

```php
public function up()
{
$this->artisan('command-name', [
// parameters
]);
}
```

## License

Expand Down
23 changes: 23 additions & 0 deletions src/Concerns/Artisan.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace DragonCode\LaravelActions\Concerns;

use Illuminate\Support\Facades\Artisan as ArtisanSupport;

trait Artisan
{
/**
* Run an Artisan console command by name.
*
* @param string $command
* @param array $parameters
*
* @return void
*/
protected function artisan(string $command, array $parameters = []): void
{
ArtisanSupport::call($command, $parameters);
}
}
3 changes: 3 additions & 0 deletions src/Support/Actionable.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
namespace DragonCode\LaravelActions\Support;

use DragonCode\Contracts\LaravelActions\Actionable as Contract;
use DragonCode\LaravelActions\Concerns\Artisan;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Arr;

abstract class Actionable extends Migration implements Contract
{
use Artisan;

/**
* Determines the type of launch of the action.
*
Expand Down

0 comments on commit e0314bc

Please sign in to comment.