Skip to content

Commit 4f9ce37

Browse files
author
maharshi
committed
User list with search option
1 parent 68dfb6b commit 4f9ce37

File tree

6 files changed

+583
-26
lines changed

6 files changed

+583
-26
lines changed

app/Http/Controllers/APIController.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,16 @@
1414

1515
class APIController extends Controller
1616
{
17-
public function users()
17+
public function users(Request $request)
1818
{
1919
try{
20-
$users = User::paginate(5);
20+
$getData = $request->all();
21+
if(isset($getData['search'])){
22+
$users = User::where('name', 'LIKE', '%' . $getData['search'] . '%')->orWhere('email', 'LIKE', '%' . $getData['search'] . '%')->paginate(5);
23+
}else{
24+
$users = User::paginate(5);
25+
}
26+
2127
$response = ['success'=>true,'message' => 'user list !!','data'=>$users];
2228
}catch (Exception $e){
2329
return [

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"sass-loader": "^8.0.0"
2727
},
2828
"dependencies": {
29+
"react-csv": "^2.0.3",
2930
"react-feather": "^2.0.8",
3031
"react-js-pagination": "^3.0.3",
3132
"react-redux": "^7.2.1",

0 commit comments

Comments
 (0)