Bird
0
0

Given this route registration:

medium📝 component behavior Q4 of 15
Laravel - Controllers
Given this route registration:
Route::apiResource('books', BookController::class);

Which URL and HTTP method will call the 'update' method in BookController?
APOST /books
BPUT /books/{book}
CGET /books/{book}
DDELETE /books/{book}
Step-by-Step Solution
Solution:
  1. Step 1: Understand 'update' method mapping

    The 'update' method handles updating a resource, which uses the PUT or PATCH HTTP method on the resource URL with an ID.
  2. Step 2: Match URL and method

    The URL pattern is '/books/{book}' and the HTTP method is PUT for updating.
  3. Final Answer:

    PUT /books/{book} -> Option B
  4. Quick Check:

    'update' method = PUT on resource URL [OK]
Quick Trick: 'update' uses PUT with resource ID URL [OK]
Common Mistakes:
  • Using GET or POST for update
  • Missing resource ID in URL
  • Confusing DELETE with update

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes