Skip to content
Back to skills

Laravel Patterns

ASecurity

Use when building Laravel apps or APIs with controllers, Eloquent, validation, resources, queues, and caching. Triggers on \"laravel-patterns\", \"laravel patterns\", \"patterns\".

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 19, 2026
ai-agentsphpapi

Works with

  • api

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned September 19, 2026

npx -y skills add majinmagros/magros.ai-skills --skill laravel-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Laravel Patterns?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Laravel Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majinmagros-laravel-patterns/badge)](https://www.skillsdirectory.com/skills/majinmagros-laravel-patterns)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: laravel-patterns
description: "Use when building Laravel apps or APIs with controllers, Eloquent, validation, resources, queues, and caching. Triggers on \"laravel-patterns\", \"laravel patterns\", \"patterns\"."
metadata:
  origin: ECC
---

# Laravel Development Patterns

Production-grade Laravel architecture: thin controllers, services/actions, typed models. Detalhes em `references/`.

## When to Activate

- Building Laravel web applications or APIs
- Structuring controllers, services, and domain logic
- Working with Eloquent models and relationships
- Designing APIs with resources and pagination
- Adding queues, events, caching, and background jobs

## Core Principles

1. **Thin controllers** — orchestration in services, single-purpose logic in actions
2. **Scoped bindings** — `scopeBindings()` for nested routes; still enforce authorization
3. **Typed models** — casts, enums, scopes; eager load (`with()`) to kill N+1
4. **IO off the request** — queues for slow work, cache for expensive reads
5. **Config discipline** — secrets in `.env`, structure in `config/*`

## Example

```php
final class OrdersController extends Controller
{
    public function __construct(private CreateOrderAction $createOrder) {}

    public function store(StoreOrderRequest $request): JsonResponse
    {
        $order = $this->createOrder->handle($request->toDto());

        return response()->json([
            'success' => true,
            'data' => OrderResource::make($order),
            'error' => null,
            'meta' => null,
        ], 201);
    }
}
```

## References

- `references/structure-routing.md` — layout, controllers/services/actions, routing, bindings, container
- `references/eloquent.md` — casts, eager loading, query objects, scopes, soft deletes, transactions
- `references/validation-api.md` — migrations, form requests + DTOs, API resources + pagination
- `references/async-cache-config.md` — events/jobs/queues, caching, configuration

## Checklist

- [ ] Controllers thin; validation in form requests with `authorize()`
- [ ] Nested routes use `scopeBindings()` with consistent parameter names
- [ ] Eloquent eager loads relations; multi-step writes in `DB::transaction`
- [ ] API responses use resources with `{success, data, error, meta}` envelope
- [ ] Slow work queued (idempotent); read-heavy paths cached with invalidation

Files in this skill

  • SKILL.md2.3 KB
  • references/async-cache-config.md936 B
  • references/eloquent.md2.7 KB
  • references/structure-routing.md3.9 KB
  • references/validation-api.md2.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…