0
我工作的搜索功能,我根據用戶輸入查詢,但我沒有得到預期的結果查詢%不給結果%像預期
//if user searches walter getting proper response
http://localhost:8000/api/v1/search/walter
{
"data": [
{
"id": 1,
"first_name": "Walter",
"last_name": "White",
"phone_number": "9665885542",
"registration_id": "12345b67892"
},
{
"id": 8,
"first_name": "Mitty",
"last_name": "Walter",
"phone_number": "8826835542",
"registration_id": "dffdfg54ty45y"
}
]
}
// but if user searches walt the response is
http://localhost:8000/api/v1/search/walt
{
"data": []
}
我的方法
//搜索驅動程序 公共職能getSearchResults($ SEARCH_INPUT){
$search_drivers = Driver::where('id', 'like', $search_input)
->orWhere('first_name', 'like', $search_input)
->orWhere('last_name', 'like', $search_input)
->orWhere('phone_number', 'like', $search_input)
->orWhere('registration_id', 'like', $search_input)
->select('id','first_name','last_name','phone_number','registration_id')
->get();
return Response::json([
'data' => $search_drivers
]);
}
有沒有更好的方式進入全數據
之前得到結果謝謝
我不好,太感謝你了真的很感激它,我不能在6分鐘內接受答案,說stackoverflow –