I came across this article on Spatie Actions https://freek.dev/1371-refactoring-to-actions and I would like to make a command to generate the files for me, similar how you can generate Model or livewire components etc.
php artisan make:action PublishPostAction Post
This is as far as I got
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class GenerateActionTemplate extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'make:action {name} {model}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new action file.';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$name = $this->argument('name');
$model = $this->argument('model');
$fileContents = <<<'EOT'
<?php
namespace App\Actions;
class PublishPostAction // name
{
private $post;
public function execute(Post $post) // model
{
$this->post = $post;
}
}
EOT;
$this->info($name . 'has been created successfully!');
}
}
- How would I do the logic, so if I do like
make:action post.PublishPostActionwould create a new folder called post inApp\Actions\Post\ - In the EOT how would I pass in the variables?
Any help or link to an example would be great! I have looked through a few tutorials and was able to scrap this up and laravel docs don't really show any example to generate a new file.

GeneratorCommandabstract class that the commands that generate files like Models and Controllers use,Illuminate\Console\GeneratorCommand... for the file content you can use a 'stub' file that allows for placeholders