So I have trying to make Autocomplete in my Project (Dictionary), and the SQL Worked normally if testing SQL Command using #Tinker.
# php artisan tinker
Psy Shell v0.9.9 (PHP 7.1.19 — cli)
>>> use App\WordsList;
>>> WordsList::where('Translation', 'english')->first();
=> App\WordsList {#2962
ID: 4,
Word: "اَلْإِنْكِلِيزِيَّة",
SimpleWords: "الإنكليزية",
Translation: "english",
Views: null,
}
>>>
but if make that in AutoComplete Controller like this:
public function search(Request $request)
{
$search = $request->get('term');
$result = WordsList::where('Translation', 'LIKE', '%'. $search. '%')->first();
return response()->json($result);
}
Web file (Routes)
Route::get('autocomplete', 'AutoCompleteController@search');
if found this problem:
## (URL) http://127.0.0.1:8000/autocomplete/?term=english
SQLSTATE[HY000] [2002] Connection refused (SQL: select * from `WordsList` where `Translation` LIKE %english% limit 1)