【发布时间】:2021-12-15 01:50:19
【问题描述】:
我需要在预约表中搜索代码或作为预约关系的患者姓名。这是我到目前为止达到的代码,但它不起作用:
$lab = Lab::select('id', 'code')
->Where('code', 'like', "%{$search_query}%")
->with(['patient' => function ($q) {
$q->select('id', 'avatar', DB::raw('CONCAT(first_Name, " ", second_Name) AS name')
->where('name', 'like', "%{$search_query}%")
->orWhereRaw("concat(first_name, ' ', second_name) like '%$search_query%' ")
);}])
->limit(5)
->get();
【问题讨论】:
-
尝试将您的代码
"%{$search_query}%"更改为'%'.$search_query.'%" -
我已经试过了,可惜没用
标签: php mysql sql laravel eloquent