Bird
0
0

When you run php artisan make:controller Api/UserController --api, which methods are included in the generated controller?

medium📝 component behavior Q5 of 15
Laravel - Controllers
When you run php artisan make:controller Api/UserController --api, which methods are included in the generated controller?
AOnly a single __invoke method
BAll resource methods including create and edit
COnly API resource methods excluding create and edit
DNo methods, just an empty controller
Step-by-Step Solution
Solution:
  1. Step 1: Understand the --api option

    The --api flag generates resource methods suitable for API controllers, excluding methods related to views.
  2. Step 2: Identify excluded methods

    Methods like create and edit are excluded because they return views.
  3. Final Answer:

    Only API resource methods excluding create and edit -> Option C
  4. Quick Check:

    --api excludes view-related methods [OK]
Quick Trick: --api excludes create/edit methods for API controllers [OK]
Common Mistakes:
  • Assuming all resource methods are included
  • Confusing --api with --invokable
  • Expecting an empty controller

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes