一键导入
controllers
Thin HTTP entry points that validate input, delegate to Actions or Services, and return a response. Controllers contain no business logic.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Thin HTTP entry points that validate input, delegate to Actions or Services, and return a response. Controllers contain no business logic.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Readonly data containers with typed factory methods (`fromArray`, `fromModel`, `fromCollection`, `fromRequest`) used to pass structured data between application layers — especially for external API responses, Eloquent models, and service boundaries. Use this skill whenever creating, reviewing, or refactoring DTOs, Data Transfer Objects, value objects for inter-layer communication, or mapping payloads from APIs, models, or collections into typed PHP objects. Also trigger when the user mentions spatie/laravel-data alternatives, data mapping, or payload normalization in a Laravel context.
Eloquent model conventions for mass assignment, casts, relationship naming, activity logging, and mandatory model tests (CRUD + relations).
Single-purpose business logic classes that encapsulate one well-defined business operation. Actions are the primary location for business logic in Laravel applications, invoked from controllers, commands, or jobs.
Albatros accounting API integration via Saloon. Use when working with app/Services/Albatros/, AlbatrosConnector, or Albatros DTOs.
Laravel Blade template conventions covering components, output escaping, security, structure, and formatting.
Artisan console command classes that serve as the CLI entry point for operations. Commands validate input and delegate all business logic to Actions or Services.
| name | controllers |
| description | Thin HTTP entry points that validate input, delegate to Actions or Services, and return a response. Controllers contain no business logic. |
| compatible_agents | ["implement","refactor","review"] |
app/Http/Controllers/**.routes/web.php, routes/api.php).FormRequest classes for all validation:
$request->validate() or Validator::make() directly in the controller.$this->authorize() calls.authorize() methods.can: or auth).__invoke):
StoreInvoiceController, ProcessWebhookController.JsonResponse or Resource / ResourceCollection).JsonResponse when status/header control matters; otherwise Laravel response casting is acceptable for simple payloads.// Invokable single-action controller
class StoreInvoiceController extends Controller
{
public function __invoke(StoreInvoiceRequest $request, CreateInvoice $action): JsonResponse
{
$invoice = $action->execute(
orderId: (int) $request->validated('order_id'),
);
return new JsonResponse(new InvoiceResource($invoice), 201);
}
}
// Resource controller — thin, delegates to actions
class InvoiceController extends Controller
{
public function index(): JsonResponse
{
// Explicit JsonResponse keeps status/header behavior clear for API controllers.
return new JsonResponse(InvoiceResource::collection(Invoice::paginate()), 200);
}
public function store(StoreInvoiceRequest $request, CreateInvoice $action): JsonResponse
{
$this->authorize('create', Invoice::class);
$invoice = $action->execute(orderId: (int) $request->validated('order_id'));
return new JsonResponse(new InvoiceResource($invoice), 201);
}
public function destroy(Invoice $invoice, DeleteInvoice $action): JsonResponse
{
$this->authorize('delete', $invoice);
$action->execute($invoice);
return new JsonResponse(null, 204);
}
}
$request->validate() directly in a controller (use a FormRequest).Actions/SKILL.md — the delegation pattern used by thin controllersFormRequests/SKILL.md — all input validationPolicies/SKILL.md — authorization enforced in controllers