🔴 Laravel
Beginner
What is a Resource Controller in Laravel?
Answer
A resource controller handles CRUD operations for a resource using a standard set of actions that map to HTTP verbs. Generate with: php artisan make:controller PostController --resource. This creates seven methods: index() (GET /posts), create() (GET /posts/create), store() (POST /posts), show($id) (GET /posts/{id}), edit($id) (GET /posts/{id}/edit), update($id) (PUT/PATCH /posts/{id}), destroy($id) (DELETE /posts/{id}). Register all routes at once: Route::resource("posts", PostController::class). Use ->only([...]) or ->except([...]) to limit which routes are registered. API resource controllers exclude create and edit (no HTML forms needed).