Tuesday 18 June 2024

Create a controller for a Laravel 11 API Model

Pre-requisites

Check to see if you already have a controller for this model. 

When the model was created using the approach in this blog post, a controller was created.

By running:
php artisan make:controller
you are provided with a list of prompts:
  1. You're asked to give it a name. I like to give it the same name as the model I just created.
  2. You're asked to select the type of controller to create. For this example, I like to select API.
  3. You're asked to select the model that this API controller would be used for. Here I name the model I just created.

No comments:

Post a Comment