Common Scenarios
Use this page when you want the fastest path from “I need X” to working commands and runtime structure.Choose a scenario
- First SQL CRUD API
- Mongo document app
- Blog with relations
- Soft delete and restore
- Cached GET endpoints
- Test-isolated artifacts
- Many-to-many favorites or tags
- Casts, scopes, and serialization
- Production-safe migrations
Scenario 1: First SQL CRUD API
Scenario 2: Mongo document app
MongoModel and explicit mongo connection names.
Scenario 3: Blog with relations
User, Post, Comment, favorites, and polymorphic comment flows quickly.
Scenario 4: Soft delete and restore
Generate restore-ready controller:Scenario 5: Cache GET endpoints
Keep cache logic in services:Scenario 6: Test-isolated artifacts
Scenario 7: Many-to-many favorites or tags
Use service-levelattach, detach, and sync flows for pivot management.
Scenario 8: Casts, scopes, and serialization
- casts normalize service reads
- scopes filter
all()andfind() toObject()gives API-safe output
Scenario 9: Production-safe migrations
Recommended order:eloquent migrate:statuseloquent db:seed:precheck --all-connectionseloquent migrate:run --all-migrations- destructive flows only with explicit
--force --yes