【发布时间】:2015-04-11 18:03:38
【问题描述】:
实际上我有 4 个相关模型并使用标准从两个表中搜索数据。如果我忽略从address 模型搜索,使用以下查询我会得到结果。但我需要从Property 和Address 模型中搜索,其中显示地址表列的错误。
$min_price = !empty($request['min_price']) ? $request['min_price'] : 500;
$max_price = !empty($request['max_price']) ? $request['max_price'] : 50000000000;
$arrCriteria = [
'properties.status' => 1,
'properties.category' => $request['search_category'],
'properties.type' => $request['contract'],
'addresses.city' => $request['search_city'], //show error
'addresses.area' => $request['property_area'], //show error
'properties.bed_room' => $request['search_bedroom'],
'properties.bath_room' => $request['bath_room'],
];
$property = Property::with('address', 'photo', 'user')
->where($arrCriteria)
->whereBetween('properties.price', [$min_price, $max_price])
->get();
【问题讨论】:
标签: php laravel laravel-4 eloquent laravel-5