Advanced Laravel Search Functionality Using Scout

Viewed 25

I have a Model named Profile in my project and i want to search user's full name through the records using Laravel Scout.

Search Function

public function SearchUser(Request $request)
{
    $searchProfileQuery = Profile::search($request->input('query'))->get();
    
    return view('users/search-result', compact('searchProfileQuery'));
}

Let's say there are 2 records :

  • Ben Hubble
  • Dean Russel

Current Condition :

  • If i search using 'e' keyword, both records are shown
  • If i search using 'dean' or 'Dean', only Dean Russel will be shown

QUESTION :

  • How if i misspelled the keyword 'Dean' with 'Dena' but Dean Russel still shown?
  • Or how if i make the keyword with excessive vowels like 'Been' but Ben Hubble still shown?

Thanks in advance.

1 Answers
Related