mgsmus hocam bu kodu yazdım fakat şöyle bir hata aldım
https://prnt.sc/cGfMZIc5f-Dp
https://prnt.sc/bvE7hv3-SWsX
Illuminate\Database\Query\Builder::whereFullText(): Argument #3 ($options) must be of type array, string given, called in C:\Users\aghab\OneDrive\Desktop\laravel-inertia-twitter-clone\vendor\laravel\framework\src\Illuminate\Support\Traits\ForwardsCalls.php on line 23
$users = User::query()
->selectRaw('id, username, name, profile_photo_path, MATCH(username, name) AGAINST(? IN BOOLEAN MODE) as score', [$search])
->whereFullText(['username', 'name'], $search, ['mode' => 'boolean'])
->orderByDesc('score')
->limit(10)
->get();
böyle yaptım düzeldi
Ekleme çok garip bir şey oldu koda
$search = htmlspecialchars($search, ENT_QUOTES, 'UTF-8');
şunu ekledim ve bulma konusunda mesela aghabala nı ag yazdığımda bile buldu. Veya a yazdığımda a isimlileri getirdi. Kısaca koda bu alanda eklenebilir.
Tam kod
$search = preg_replace('/[+\-*><()~"@]/', '', trim(request('search')));
$search = htmlspecialchars($search, ENT_QUOTES, 'UTF-8');
if(!$search) {
return response()->json([]);
}
$search .= '*';
$users = User::query()
->selectRaw('id, username, name, profile_photo_path, MATCH(username, name) AGAINST(? IN BOOLEAN MODE) as score', [$search])
->whereFullText(['username', 'name'], $search, ['mode' => 'boolean'])
->orderByDesc('score')
->limit(10)
->get();