Generate Laravel CRUD Scaffold
Generate a complete Laravel CRUD scaffold for the given entity.
What To Do
- Model with Eloquent fillable, casts, relations, and factory() link
- Migration with typed columns, nullable constraints, foreign keys, and indexes
- Controller as resource controller (index, store, show, update, destroy)
- FormRequest with authorize() and rules() for create and update validation
- Factory with Faker definitions for all fillable fields
- Seeder calling the factory for demo data
- Policy with viewAny, view, create, update, delete, restore, forceDelete
- API Resource (JsonResource) for consistent response transformation
- Routes entry with Route::apiResource or Route::resource
- PHPUnit test covering CRUD HTTP endpoints
Structure
app/
Models/{EntityName}.php
Http/Controllers/{EntityName}Controller.php
Http/Requests/Store{EntityName}Request.php
Http/Requests/Update{EntityName}Request.php
Http/Resources/{EntityName}Resource.php
Policies/{EntityName}Policy.php
database/
migrations/{timestamp}_create_{entity_name_plural}_table.php
factories/{EntityName}Factory.php
seeders/{EntityName}Seeder.php
tests/Feature/
{EntityName}ControllerTest.php
Patterns
- declare(strict_types=1) on every generated PHP file
- Constructor property promotion in FormRequest constructors
- Route model binding: type-hinted model in method signatures
- RefreshDatabase trait on the test class
Arguments
<entity-name>: Entity name in PascalCase (e.g., JobOffer, Candidate)--api: API-only mode — generates apiResource routes and skips web views