laravel search multiple words separated by space

前端 未结 7 1951
鱼传尺愫
鱼传尺愫 2020-12-29 08:57

I am new to laravel query builder, I want to search multiple words entered in an input field for example if I type \"jhon doe\" I want to get any column that contains jhon o

7条回答
  •  甜味超标
    2020-12-29 09:39

     $keywordRaw = "jhon doe";
        $key = explode(' ',$keywordRaw)
        $users = User::select('users.*')
        ->whereIn('first_name',$key);
    

    This would work.the whereIn would search for first name from the keywords you entered.

提交回复
热议问题