I have the following code and expect to pass $search into the raw query:
$tags = Tag::whereHas('translations', function ($query) use ($search) {
$query->whereRaw("MATCH(`name`) AGAINST(? IN BOOLEAN MODE)", [$search]);
echo $query->toSql();
})->get();
SQL dump:
select * from `tag_translation` where `tag_translation`.`tag_id` = `tag`.`id` and MATCH(`name`) AGAINST(? IN BOOLEAN MODE)
The ? is not replaced by $search.
Cannot find useful document about the whereRaw() function. Is here any good way to excute a raw SQL for fulltext index?