Created
June 6, 2023 10:58
-
-
Save johnadan/567a40f92dcf4fd26de4d0903dddce4f to your computer and use it in GitHub Desktop.
List with query params in laravel api controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function index(Request $request) | |
{ | |
UserLog::insertLog('Listed cities', URL::full()); | |
$cities = AddressCity::query(); | |
$provinceCode = $request->provinceCode; | |
if ($provinceCode) { | |
$cities = $cities->where('province_code', $provinceCode); | |
} | |
return response()->json([ | |
'cities' => $cities->paginate(10) | |
]); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment