Bird
0
0

Given this resource controller route registration:

medium📝 component behavior Q13 of 15
Laravel - Controllers
Given this resource controller route registration:
Route::resource('photos', PhotoController::class);
Which URL and HTTP method will call the destroy method in PhotoController for photo with ID 5?
APUT /photos/5/destroy
BGET /photos/5/destroy
CPOST /photos/5/delete
DDELETE /photos/5
Step-by-Step Solution
Solution:
  1. Step 1: Recall resource route conventions for destroy

    The destroy method is called with HTTP DELETE on the resource URI with the ID, e.g., DELETE /photos/{id}.
  2. Step 2: Match options to this pattern

    DELETE /photos/5 matches DELETE /photos/5. Other options use wrong HTTP methods or incorrect URLs.
  3. Final Answer:

    DELETE /photos/5 -> Option D
  4. Quick Check:

    Destroy = DELETE /resource/{id} [OK]
Quick Trick: Destroy uses DELETE method on /resource/{id} URL [OK]
Common Mistakes:
  • Using GET or POST instead of DELETE for destroy
  • Adding extra path segments like /destroy or /delete
  • Confusing PUT with DELETE method

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes