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/laravel-vue-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.
653baseline-ui
Enforces an opinionated UI baseline to prevent AI-generated interface slop.
28laravel-laravel-prompting-patterns
Use Laravel-specific vocabulary—Eloquent patterns, Form Requests, API resources, jobs/queues—to get idiomatic framework code
28laravel-data-chunking-large-datasets
Process large datasets efficiently using chunk(), chunkById(), lazy(), and cursor() to reduce memory consumption and improve performance
28laravel-performance-caching
Use framework caches and value/query caching to reduce work; add tags, locks, and explicit invalidation strategies for correctness
28complexity-guardrails
Keep cyclomatic complexity low; flatten control flow, extract helpers, and prefer table-driven/strategy patterns over large switches
28