Menu
About LCS
Projects
All snippet related to projects
Adding a Poll record with validation in restful api
Step 01: Setting up route for store() method in PollController in routes/api.php Route::post( '/polls', [PollController::class,'store']); Step 02: Adding store() method...
Topic:
Restful API
3 years ago
Editing a Poll record with validation
Step 01: setting up route for store() method in PollController in routes/api.php Route::put( '/polls/{id}', [PollController::class,'update']); Step 02: adding update() method...
Topic:
Restful API
3 years ago
Deleting a Poll record with validation
Step 01: setting up route for delete() method in PollController in routes/api.php Route::delete( '/polls/{id}', [PollController::class,'delete']); Step 02: adding delete() method...
Topic:
Restful API
3 years ago
Searching Poll records with query string and using eloquent when
We will be changing index() method like below of PollController for this purpose //In PollController.phppublic function index() { //dd(request('search_title')); $polls...
Topic:
Restful API
3 years ago
Using transformers to transform api response data
Sometimes our api response data need to be transferred in certain way to achive our desired need. For example, formatting...
Topic:
Restful API
3 years ago
Seeding Question data for a poll
Step 01: running artisan command to create question factory, seeder, migration and model files php artisan make:model Question -mfs Step...
Topic:
Restful API
3 years ago
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...
Topic:
Restful API
3 years ago
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...
Topic:
Restful API
3 years ago
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...
Topic:
Restful API
3 years ago
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() {...
Topic:
Restful API
3 years ago
‹
1
2
3
4
5
6
7
8
9
10
›