laravel-routes-best-practices
Routes Best Practices
Keep your route files clean and focused on mapping requests to controllers. Routes should never contain business logic, validation, or database operations.
Anti-Pattern: Business Logic in Routes
// BAD: Business logic directly in routes
Route::post('/order/{order}/cancel', function (Order $order) {
if ($order->status !== 'pending') {
return response()->json(['error' => 'Cannot cancel'], 400);
}
$order->status = 'cancelled';
$order->cancelled_at = now();
$order->save();
Mail::to($order->user)->send(new OrderCancelled($order));
More from noartem/skills
shadcn-vue
shadcn-vue for Vue/Nuxt with Reka UI components and Tailwind. Use for accessible UI, Auto Form, data tables, charts, dark mode, MCP server setup, or encountering component imports, Reka UI errors.
76baseline-ui
Enforces an opinionated UI baseline to prevent AI-generated interface slop.
24complexity-guardrails
Keep cyclomatic complexity low; flatten control flow, extract helpers, and prefer table-driven/strategy patterns over large switches
23laravel-debugging-prompts
Create effective debugging prompts—include error messages, stack traces, expected vs actual behavior, logs, and attempted solutions
23laravel-api
Build production-grade Laravel REST APIs using opinionated architecture patterns with Laravel best practices. Use when building, scaffoling, or reviewing Laravel APIs with specifications for stateless design, versioned endpoints, invokable controllers, Form Request DTOs, Action classes, JWT authentication, and PSR-12 code quality standards. Triggers on "build a Laravel API", "create Laravel endpoints", "add API authentication", "review Laravel API code", "refactor Laravel API", or "improve Laravel code quality".
23laravel-api-resources-and-pagination
Use API Resources with pagination and conditional fields; keep response shapes stable and cache-friendly
22