Create a new laravel command to generate a custom file in the /App directory
Budget: $10 – $30 USD
Please read this brief carefully, as this is the best explanation I can give. If you have NEVER created commands in laravel, please do not apply or message me.
I am looking to create a command to create a new Action file, as outlined in this approach on this blog https://freek.dev/1371-refactoring-to-actions
The file I want to create is for something to look like this.
<?php
namespace App\Actions;
use App\Models\Post;
class PublishPostAction
{
private $post;
public function execute(Post $post)
{
$this->post = $post;
}
}
I have attached what I tried to make with the PHP artisan make:command but, I am stuck with this.
I would like to run a command `php artisan make:action PublishPostAction Post` and the class name would be PublishPostAction and the other variables would be from the model Post
Also, if I do a command like `php artisan make:action post.PublishPostAction Post` for it to create the file in a new directory called post.
I was directed to look into the GeneratedComand in laravel, but this is beyond my scope of understanding https://github.com/laravel/framework/blob/9.x/src/Illuminate/Console/GeneratorCommand.php
The deliverable for this project is 1 that I can copy to make this command work.
I am looking to create a command to create a new Action file, as outlined in this approach on this blog https://freek.dev/1371-refactoring-to-actions
The file I want to create is for something to look like this.
<?php
namespace App\Actions;
use App\Models\Post;
class PublishPostAction
{
private $post;
public function execute(Post $post)
{
$this->post = $post;
}
}
I have attached what I tried to make with the PHP artisan make:command but, I am stuck with this.
I would like to run a command `php artisan make:action PublishPostAction Post` and the class name would be PublishPostAction and the other variables would be from the model Post
Also, if I do a command like `php artisan make:action post.PublishPostAction Post` for it to create the file in a new directory called post.
I was directed to look into the GeneratedComand in laravel, but this is beyond my scope of understanding https://github.com/laravel/framework/blob/9.x/src/Illuminate/Console/GeneratorCommand.php
The deliverable for this project is 1 that I can copy to make this command work.