chore: add command to generate actions

use `artisan make:action <name>` to generate final & readonly php class with execute method.
This commit is contained in:
kusowl 2026-02-26 16:05:03 +05:30
parent 6419adb7d1
commit 30bc4a0cf3
2 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,32 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\GeneratorCommand;
class MakeActionCommand extends GeneratorCommand
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'make:action {name}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new action class';
protected function getStub(): string
{
return base_path('stubs/action.stub');
}
protected function getDefaultNamespace($rootNamespace): string
{
return $rootNamespace.'\Actions';
}
}

14
backend/stubs/action.stub Normal file
View File

@ -0,0 +1,14 @@
<?php
namespace {{ namespace }};
final readonly class {{ class }}
{
/**
* Execute the action.
*/
public function execute()
{
// Your logic here
}
}