-
Open your Terminal window and type the following command:
php artisan make:controller API/BuilderController --api
Note that the --api flag creates four methods for us inside the BuilderController class:
- index() = GET
- store() = POST
- show($id) = GET
- update(Request $request, $id) = PUT
- destroy($id) = POST
-
Open project/app/Http/Controllers/API/BuilderController.php and add the App\Builder code right after the Controller import.
-
Now, let's add the content for each method. Open project/app/Http/Controllers/API/BuilderController.php and replace the content with the following code:
<?phpnamespace App\Http\Controllers\API;use Illuminate\Http\Request;use App\Http\Controllers\Controller;use App\Builder; ...