Restful API

It uses stateless protocol for communication between applications. There are four types of protocol which are also known HTTP verbs. They are GET, POST, PUT and DELETE. They are setup in resources which are called endpoints and these resources are setup in such manner that based upon HTTP verb proper response is thrown.
 

Bulding endpoints for Question resources

Similar to Poll resource we will be implementing endpoints for question resources that is browsing, adding, reading, editing and deleting...


Browsing Poll Questions in restful api

Step 01: Setting up routes in routes/api.php Route::get( '/polls/{poll}/questions', [PollController::class, 'questions'] ); Step 02: Back in PollController.php adding questions() method...


Fetching questions under poll in restful api ( nested data )

Step 01: In PollController changing setup like below from previous setup public function show($id) { $poll = Poll::find($id); if(is_null($poll)){ return...


Pagination for poll in restful api

It is achieved in simple one step process like below by modifying index() method in PollController.php public function index() {...


Returning a file (image or pdf) in restful api

It is achieved in two simple steps like below after running artisan command for making new controller named FileController.php (...


Uploading image in restful api

It is achieved in two simple steps like below in FileController.phpStep 01: Setting up route for file uploading //at the...


How to use REST Client extension in VS Code to test Laravel API routes easily

Many of us use Postman to test our Rest APIs, switching between vscode and postman. But what if there is...