这是我的代码:
$prestations = Prestation::with(
[
'service' => function($service) use($searchService) {
$service->select(['id','name'])->where('name', 'regexp', "/$searchService/i");
},
'facility' => function($facility) use($searchPartenaire) {
$facility->select(['id','name'])->where('name', 'regexp', "/$searchPartenaire/i");
}
]
)
->where('name', 'regexp', "/$search/i")
->orderBy($orderBy, $orderDirection)
->simplePaginate(50);
$res = [
'results' => $prestations,
'total' => Prestation::all()->count(),
];
问题在于,在 $searchService 和 $searchPartenaire 上“服务”和“设施”名称不相等的所有数据的输出中,值被“空”替换。所以我不想在搜索变量不等于的输出中有值。
LEATH
潇潇雨雨
青春有我