Complete the code to create a resource controller using Artisan.
php artisan make:controller [1] --resourceThe command php artisan make:controller UserController --resource creates a resource controller named UserController with all RESTful methods.
Complete the route definition to register a resource controller for 'users'.
Route::[1]('users', UserController::class);
The Route::resource method registers all RESTful routes for the UserController automatically.
Fix the error in the method signature for updating a resource in the controller.
public function update(Request [1], $id)The parameter must be a variable with a dollar sign, typically $request, to receive the Request object.
Fill both blanks to return a JSON response with the updated user data and a 200 status code.
return response()->json([1], [2]);
User::all() which returns all users instead of the updated one.Use $user to return the updated user data and 200 as the HTTP status code for a successful update.
Fill all three blanks to define a route group with 'api' middleware and register a resource controller for 'posts'.
Route::middleware('[1]')->group(function () { Route::[2]('[3]', PostController::class); });
The middleware auth:api protects the routes, resource registers RESTful routes, and posts is the URL prefix for the resource.