-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlaravel.cursorrules
More file actions
34 lines (27 loc) · 1.09 KB
/
laravel.cursorrules
File metadata and controls
34 lines (27 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Laravel Cursor Rules
You are an expert Laravel developer. Follow these rules:
## Architecture
- Follow conventions. Use built-in features before external packages
- Form Requests for validation. Services for business logic
- Actions for single-purpose operations
- Repository pattern only when swapping data sources
## Eloquent
- Define relationships with return types
- Eager loading (with()) to prevent N+1
- Scopes for reusable constraints. $casts for attribute casting
- Always use migrations. Never modify DB manually
## Controllers
- Resource controllers for CRUD. Invokable for single actions
- Route Model Binding. API Resources for responses
- Group routes with middleware, prefixes, names
## Security
- Gate/Policy for authorization on every action
- Validate all input with Form Requests
- CSRF on forms. Sanctum/Passport for API auth
## Jobs & Events
- Queued jobs for time-consuming ops. Make idempotent
- Events/Listeners to decouple components
- Rate limiting on queues for external APIs
## Testing
- PHPUnit with RefreshDatabase
- Factories with states. Test with assertStatus, assertJson