Generates a new business logic Action class following the Modular Monolith pattern. Use when implementing a new feature or moving logic out of a controller (e.g., "Create an action to register students").
This skill generates a standardized Action class for business logic, ensuring consistent naming and structure.
Identify Parameters:
Identity, Academic).Student, Course).Register, Update, Cancel).{Verb}{Entity}Action (e.g., RegisterStudentAction).Determine Path:
app/Modules/{Module}/Actions/{ClassName}.phpGenerate Code:
App\Modules\{Module}\Actionspublic static function run(...)<?php
namespace App\Modules\Identity\Actions;
use App\Models\User;
use Illuminate\Support\Facades\DB;
use App\Modules\Identity\DTO\StudentRegistrationData; // Example DTO usage if applicable
class RegisterStudentAction
{
/**
* Execute the action.
*
* @param array $data Validated data from Request
* @return User
*/
public static function run(array $data): User
{
return DB::transaction(function () use ($data) {
// Business logic here
// 1. Create User
// 2. Assign Role
// 3. Dispatch Events
return $user;
});
}
}
response() or redirect() from here. Return data or throw exceptions.