$cases = DB::table('cases')->where('cid',$cid)->when($condition,function($query) use($condition){
return $query->where(function($query) use($condition){
$query->orwhere('title','like','%'.$condition.'%')->orwhere('style','like','%'.$condition.'%')->orwhere('address','like','%'.$condition.'%');
});
})->when($default,function($query) use($default){
return $query->where(function($query) use($default){
$query->where('style','like','%'.$default.'%');
});
})->when($time == 1,function($query){
return $query->orderBy('addtime','desc');
})->when($time == 0,function($query){
return $query->orderBy('addtime','asc');
})->when($hot == 1,function($query){
return $query->orderBy('hot','desc');
})->when($hot == 0,function($query){
return $query->orderBy('hot','asc');
})->when($minarea > 0 && $maxarea > 0,function($query) use($minarea,$maxarea){
return $query->wherebetween('area',[$minarea,$maxarea]);
})->when($minarea > 0 && $maxarea == 0,function($query) use($minarea){
return $query->where('area','>=',$minarea);
})->when($minarea == 0 && $maxarea > 0,function($query) use($maxarea){
return $query->where('area','<=',$maxarea);
})
->orderBy('sort','desc')->paginate($pageSize,['*'],'page',$pageNo);
// dd( DB::getQueryLog());
foreach ($cases as $k => $v) {
$cases[$k]->photo = $this->upload.$v->photo;
// if ($v->panorama && empty($v->url)) {
// $cases[$k]->url = 'http://www.homeeyes.cn/app/3DShow/index.html?type=1&case_id='.$v->id;
// }
// $cases[$k]->author = DB::table('admin_users')->where('id',$v->uid)->select('name','avatar')->first();
// if ($cases[$k]->author) {
// $cases[$k]->author->avatar = $this->upload.$cases[$k]->author->avatar;
// }
}
return response()->json(['error'=>0,'data'=>$cases]);