【发布时间】:2023-03-27 10:25:02
【问题描述】:
我正在定制一个基于 octoberCMS(基于 laravel)的预建项目。 Bellow 是一个现有的查询 sn-ps,我想在其中添加更多的“AND”和“OR”条件。
注释掉是我需要做的简单的话或接近 程序风格
$records = DB::orderBy('id', 'desc');
$records = $records->where(function($q){
$q->where(function($q){
//Get all employees
$q->where('assigned_id', Auth::getUser()->id);
});
//I need to add "OR (' "column_x" = "whatever" AND "column_y" = "whatever" ')"
$q->orWhere(function($q){
$q->whereHas('manifest', function($q){
$q->where(function($q) {
$q->where('driver_id', Auth::getUser()->id);
});
$q->orWhere(function($q){
$q->where('employee_id', Auth::getUser()->id);
});
});
});
});
【问题讨论】:
标签: mysql octobercms