$type($merchant_id,$id); } /** * 活动 * @param $merchant_id * @param $id * @return mixed */ private function activity($merchant_id, $id) { $where = [ ['class','=','one'] ]; if ($merchant_id) { $where[] = ['merchant_id', '=', $merchant_id]; } if ($id) { $where[] = ['id', '=', $id]; } $data = CommunityActivity::where($where) ->orderBy('id', 'desc') ->first(); if($data){ $data->sku = json_decode($data->sku); $data->merchant = MerchantAccount::with('anchorV2')->where('id',$data->merchant_id)->first(); } return $data; } /** * 咨询 * @param $merchant_id * @param $id * @return Consultation|Consultation[]|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model|object */ private function consultation($merchant_id, $id) { $where = []; if ($id) { $where[] = ['id', '=', $id]; } $data = Consultation::with('teacher') ->whereHas('teacher', function ($query) use ($merchant_id) { if ($merchant_id) { $query->where('merchant_id', $merchant_id); } }) ->where($where) ->orderBy('id', 'desc') ->first(); if($data){ $data->merchant = MerchantAccount::with('anchorV2')->where('id',$data->teacher->merchant_id)->first(); } return $data; } /** * 课程 * @param $merchant_id * @param $id * @return mixed */ private function course($merchant_id, $id) { $where = []; if ($merchant_id) { $where[] = ['merchant_id', '=', $merchant_id]; } if ($id) { $where[] = ['id', '=', $id]; } $data = Course::where($where)->orderBy('id', 'desc')->first(); if($data){ $data->merchant = MerchantAccount::with('anchorV2')->where('id',$data->merchant_id)->first(); } return $data; } /** * 测评 * @param $merchant_id * @param $id * @return mixed */ private function evaluation($merchant_id, $id) { $where = []; if ($merchant_id) { $where[] = ['merchant_id', '=', $merchant_id]; } if ($id) { $where[] = ['id', '=', $id]; } $data = MerchantEvaluate::where($where)->orderBy('id','desc')->first(); if($data){ $data->merchant = MerchantAccount::with('anchorV2')->where('id',$data->merchant_id)->first(); } return $data; } /** * 服务 * @param $merchant_id * @param $id * @return mixed */ private function service($merchant_id, $id) { $where = [ ['class','=','many'] ]; if($merchant_id){ $where[] = ['merchant_id','=',$merchant_id]; } if ($id) { $where[] = ['id', '=', $id]; } $data = CommunityActivity::where($where) ->orderBy('id', 'desc') ->first(); if($data){ $data->sku = json_decode($data->sku); $data->merchant = MerchantAccount::with('anchorV2')->where('id',$data->merchant_id)->first(); } return $data; } /** * 福恋vip * @param $merchant_id * @param $id * @return array */ private function vip($merchant_id, $id) { return []; } /** * 商品 */ private function shop($merchant_id, $id) { $where = [ ]; if($merchant_id){ $where[] = ['merchant_id','=',$merchant_id]; } if ($id) { $where[] = ['id', '=', $id]; } $data = MerchantShop::where($where) ->orderBy('id', 'desc') ->first(); if($data){ $data->sku = json_decode($data->sku); $data->merchant = MerchantAccount::with('anchorV2')->where('id',$data->merchant_id)->first(); } return $data; } }