laravel:nova:resource-patterns
Nova Resource Patterns
Build consistent Nova resources that mirror domain models and evolve safely.
Fields
- Keep fields ordered: identifiers → primary attributes → relations → meta
- Use
->sortable()/->filterable()where it delivers value - Hide sensitive fields (e.g., tokens) from index/detail unless necessary
- Prefer
BelongsTo/HasMany/Morph*relations with searchable constraints
Authorization
- Use Nova policies mirroring model policies for
viewAny,view,create,update,delete - Avoid leaking existence via unauthorized search; scope queries
Actions
- Keep actions idempotent or provide safeguards
- Provide confirmation messages and clear result feedback
Filters & Lenses
- Filters: simple, commonly used constraints (status, owner, date range)
- Lenses: opinionated, task‑centric views (e.g., stale items)
Metrics
- Value/Trend/Partition metrics for essentials; cache appropriately
- Use explicit time ranges; label units clearly
Resource Organization
- Group resources by domain (navigation grouping)
- Keep display titles meaningful; use
title()consistently
Testing
- Prefer feature tests that exercise policy + query scope + resource logic
- For actions, test success and failure states with realistic seed data
More from jpcaparas/superpowers-laravel
laravel:routes-best-practices
Keep routes clean and focused on mapping requests to controllers; avoid business logic, validation, or database operations in route files
89laravel:blade-components-and-layouts
Compose UIs with Blade components, slots, and layouts; keep templates pure and testable
89laravel:quality-checks
Unified quality gates for Laravel projects; Pint, static analysis (PHPStan/Psalm), Insights (optional), and JS linters; Sail and non-Sail pairs provided
80laravel:performance-caching
Use framework caches and value/query caching to reduce work; add tags, locks, and explicit invalidation strategies for correctness
77laravel:eloquent-relationships
Define clear relationships and load data efficiently; prevent N+1, use constraints, counts/sums, and pivot syncing safely
76laravel:queues-and-horizon
Operate and verify queues with or without Horizon; safe worker flags, failure handling, and test strategies
75