Complete the code to define a route that responds to a GET request.
Route::[1]('/home', function () { return 'Welcome Home'; });
The get method defines a route that responds to HTTP GET requests.
Complete the code to define a route that handles a POST request to '/submit'.
Route::[1]('/submit', function () { return 'Form submitted'; });
The post method defines a route that handles HTTP POST requests, commonly used for submitting data.
Fix the error in the route definition to correctly handle a PUT request to update a resource.
Route::[1]('/user/{id}', function ($id) { return "User $id updated"; });
The put method is used for updating resources in RESTful routing.
Fill both blanks to define a route that deletes a post by ID using the DELETE method.
Route::[1]('/post/[2]', function ($id) { return "Post $id deleted"; });
The delete method defines a route for HTTP DELETE requests. The {id} is a route parameter for the post ID.
Fill all three blanks to define a route group with prefix 'api' and a POST route to 'login'.
Route::prefix('[1]')->group(function () { Route::[2]('[3]', function () { return 'API login'; }); });
The prefix method groups routes under a common URL prefix. Inside, Route::post defines a POST route to 'login'.