我正在使用Laravel 5的可赞美产品。在我的float
模型中,我具有此功能
PartnersVehicles
表加载正常,但是当我尝试在搜索框中执行ajax搜索时,我在下面收到此错误
违反完整性约束:1052 where子句中的“ make”列不明确(SQL:从 public static function laratablesQueryConditions($query)
{
$uid = Auth::id(); //user ID
$pid = Partners::where('uid', $uid)->first(); //get partner ID
return $query->select('partners_vehicles.id', 'partners_vehicles.year', 'vehicle_makes.make', 'partners_vehicles.model', 'vehicle_colors.color', 'partners_vehicles.created_at')
->join('vehicle_makes', 'vehicle_makes.id', '=', 'partners_vehicles.make')
->join('vehicle_colors', 'vehicle_colors.id', '=', 'partners_vehicles.color')
->where('partners_vehicles.partner_id', $pid->id);
}
上的partners_vehicles
内部联接vehicle_makes
中选择count(*)作为聚合。{{1 }} = vehicle_makes
。id
在partners_vehicles
上进行内部连接make
。vehicle_colors
= vehicle_colors
。id
其中{{1} }。partners_vehicles
= 7,而{color
如%2%或partners_vehicles
如%2%或partner_id
如%2%或year
如%2% ))
我尝试将选择内容更改为此,但是仍然没有运气
make
有什么解决办法吗?我想念什么?谢谢
答案 0 :(得分:0)
尝试此代码
public static function laratablesQueryConditions($query)
{
$uid = Auth::id(); //user ID
$pid = Partners::where('uid', $uid)->first(); //get partner ID
$res=DB::table('partners_vehicles')
->select('partners_vehicles.id', 'partners_vehicles.year', 'vehicle_makes.make', 'partners_vehicles.model', 'vehicle_colors.color', 'partners_vehicles.created_at')
->join('vehicle_makes', 'vehicle_makes.id', '=', 'partners_vehicles.make')
->join('vehicle_colors', 'vehicle_colors.id', '=', 'partners_vehicles.color')
->where('partners_vehicles.partner_id','=', $pid->id)
->get();
return $res;
}