laravel search multiple words separated by space

前端 未结 7 1970
鱼传尺愫
鱼传尺愫 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条回答
  •  猫巷女王i
    2020-12-29 09:30

    You can use this package https://github.com/nicolaslopezj/searchable

    or just do this, if you don't want to use package

    $keywordRaw = "jhon doe";
    $users = User::where('first_name', 'LIKE', $keywordRaw.'%')
    ->orWhere('first_name', 'LIKE', '% '.$keywordRaw.'%')
    ->get();
    

提交回复
热议问题