How to use getById method of data class

Best Atoum code snippet using data.getById

PublicacionController.php

Source:PublicacionController.php Github

copy

Full Screen

...35 $this->view("navbar", "");36 $this->view("publicaciones", $datosUsuario);37 if (isset($publicaciones[0])){38 foreach ($publicaciones as $publicacion){39 $dir_o = $direccionModel->getById($publicacion->id_direccion_origen);40 $dir_o = array(41 'calle' => $dir_o->calle,42 'numero' => $dir_o->numero,43 'piso' => $dir_o->piso,44 'depto' => $dir_o->depto,45 'descripcion' => $dir_o->descripcion, 46 'id_provincia' => $dir_o->id_provincia,47 'id_ciudad' => $dir_o->id_ciudad,48 'provincia' => $provinciaModel->getById($dir_o->id_provincia)->nombre,49 'ciudad' => $ciudadModel->getById($dir_o->id_ciudad)->nombre50 );51 $dir_d = $direccionModel->getById($publicacion->id_direccion_destino);52 $dir_d = array(53 'calle' => $dir_d->calle,54 'numero' => $dir_d->numero,55 'piso' => $dir_d->piso,56 'depto' => $dir_d->depto,57 'descripcion' => $dir_d->descripcion, 58 'id_provincia' => $dir_d->id_provincia,59 'id_ciudad' => $dir_d->id_ciudad,60 'provincia' => $provinciaModel->getById($dir_d->id_provincia)->nombre,61 'ciudad' => $ciudadModel->getById($dir_d->id_ciudad)->nombre62 );63 // $comentarios = (array)$comentarioModel->getByAsArray('id_publicacion', $publicacion->id);64 $comentarios = (array)$comentarioModel->getComentariosPublicacion($publicacion->id);65 // echo '<pre>'; print_r($comentarios); exit();66 for ($i = 0; $i < count($comentarios); $i++){67 $usuario = $usuarioModel->getById($comentarios[$i]['id_usuario']);68 $comentarios[$i]['usuario'] = $usuario->nombre;69 $comentarios[$i]['usuario_avatar'] = $usuario->avatar;70 if (!empty($comentarios[$i]['id_usuario_respuesta']))71 $comentarios[$i]['usuario_respuesta'] = $usuarioModel->getById($comentarios[$i]['id_usuario_respuesta'])->nombre; 72 }73 //echo '<pre>'; print_r($comentarios); exit();74 // $postulantes = $postulacionModel->getByAsArray('id_publicacion', $publicacion->id);75 $data = array(76 'publicacion' => (array)$publicacion,77 'dir_o' => $dir_o,78 'dir_d' => $dir_d,79 'usuario' => (array)($usuarioModel->getById($publicacion->id_usuario)),80 'comentarios' => $comentarios81 // 'postulantes' => $postulantes82 );83 $this->view("publicacion", $data);84 // $this->view("comentarios", $data);85 }86 } else {87 $this->view("errorBusqueda", "");88 }89 $this->view("footer", "");90 }91 public function buscar(){92 session_start();93 if (!isset($_SESSION['id']))94 $this->redirect('publicacion', 'index');95 $publicaciones = new PublicacionModel();96 $direccionModel = new DireccionModel();97 $ciudadModel = new CiudadModel();98 $provinciaModel = new ProvinciaModel();99 $comentarioModel = new ComentarioModel();100 $usuarioModel = new UsuarioModel();101 $vehiculoModel = new VehiculoModel();102 $postulacionModel = new PostulacionModel();103 // echo $_POST['fb_tipo_vehiculo']; exit();104 $where = "WHERE publicacion.estado != 2 ";105 $where .= (!empty($_POST['fb_titulo'])) ? " AND publicacion.titulo LIKE '%" .$_POST['fb_titulo']."%'" : "";106 $where .= (!empty($_POST['fb_fecha_salida'])) ? " AND publicacion.fecha_salida = DATE('" .$_POST['fb_fecha_salida']."')" : "";107 $where .= ($_POST['fb_tipo_vehiculo']!="") ? " AND publicacion.tipo_vehiculo = '" .$_POST['fb_tipo_vehiculo']."'" : "";108 $where .= ($_POST['fb_id_provincia']!=0) ? " AND ubi.id_provincia = " .$_POST['fb_id_provincia'] : "";109 $where .= ($_POST['fb_id_ciudad']!=0) ? " AND ubi.id_ciudad = " .$_POST['fb_id_ciudad'] : "";110 //$where = substr($where, 0, -2);111 // echo $where; exit();112 $publicaciones = $publicaciones->getPublicacionesFiltro($where);113 $_SESSION['vehiculos'] = $vehiculoModel->getByAsArray('id_usuario', $_SESSION['id']);114 // $data['vehiculos'] = $vehiculoModel->getByAsArray('id_usuario', $_SESSION['id']);115 //echo '<pre>';print_r($data); exit();116 $this->view("header", "");117 $this->view("navbar", "");118 $this->view("buscarPublicaciones", "");119 $this->view("publicaciones", "");120 if (isset($publicaciones[0])){121 foreach ($publicaciones as $publicacion){122 $dir_o = $direccionModel->getById($publicacion->id_direccion_origen);123 $dir_o = array(124 'calle' => $dir_o->calle,125 'numero' => $dir_o->numero,126 'piso' => $dir_o->piso,127 'depto' => $dir_o->depto,128 'descripcion' => $dir_o->descripcion, 129 'id_provincia' => $dir_o->id_provincia,130 'id_ciudad' => $dir_o->id_ciudad,131 'provincia' => $provinciaModel->getById($dir_o->id_provincia)->nombre,132 'ciudad' => $ciudadModel->getById($dir_o->id_ciudad)->nombre133 );134 $dir_d = $direccionModel->getById($publicacion->id_direccion_destino);135 $dir_d = array(136 'calle' => $dir_d->calle,137 'numero' => $dir_d->numero,138 'piso' => $dir_d->piso,139 'depto' => $dir_d->depto,140 'descripcion' => $dir_d->descripcion, 141 'id_provincia' => $dir_d->id_provincia,142 'id_ciudad' => $dir_d->id_ciudad,143 'provincia' => $provinciaModel->getById($dir_d->id_provincia)->nombre,144 'ciudad' => $ciudadModel->getById($dir_d->id_ciudad)->nombre145 );146 // $comentarios = (array)$comentarioModel->getByAsArray('id_publicacion', $publicacion->id);147 $comentarios = (array)$comentarioModel->getComentariosPublicacion($publicacion->id);148 // echo '<pre>'; print_r($comentarios); exit();149 for ($i = 0; $i < count($comentarios); $i++){150 $usuario = $usuarioModel->getById($comentarios[$i]['id_usuario']);151 $comentarios[$i]['usuario'] = $usuario->nombre;152 $comentarios[$i]['usuario_avatar'] = $usuario->avatar;153 if (!empty($comentarios[$i]['id_usuario_respuesta']))154 $comentarios[$i]['usuario_respuesta'] = $usuarioModel->getById($comentarios[$i]['id_usuario_respuesta'])->nombre; 155 }156 //echo '<pre>'; print_r($comentarios); exit();157 // $postulantes = $postulacionModel->getByAsArray('id_publicacion', $publicacion->id);158 $data = array(159 'publicacion' => (array)$publicacion,160 'dir_o' => $dir_o,161 'dir_d' => $dir_d,162 'usuario' => (array)($usuarioModel->getById($publicacion->id_usuario)),163 'comentarios' => $comentarios164 // 'postulantes' => $postulantes165 );166 $this->view("publicacion", $data);167 // $this->view("comentarios", $data);168 }169 } else {170 $this->view("errorBusqueda", "");171 }172 $this->view("footer", "");173 }174 public function publicacion(){175 session_start();176 if (!isset($_SESSION['id']))177 $this->redirect('publicacion', 'index');178 $publicacion = new PublicacionModel();179 if ($publicacion = $publicacion->getById($_GET['id_publicacion'])){180 $direccionModel = new DireccionModel();181 $ciudadModel = new CiudadModel();182 $provinciaModel = new ProvinciaModel();183 $comentarioModel = new ComentarioModel();184 $usuarioModel = new UsuarioModel();185 $vehiculoModel = new VehiculoModel();186 $postulacionModel = new PostulacionModel();187 $datosUsuario = $usuarioModel->getDatosEnvios($_SESSION['id']);188 $datosUsuario['postulacion_activa'] = $usuarioModel->getPostulacionActiva($_SESSION['id'])['id'];189 $_SESSION['vehiculos'] = $vehiculoModel->getByAsArray('id_usuario', $_SESSION['id']);190 // $data['vehiculos'] = $vehiculoModel->getByAsArray('id_usuario', $_SESSION['id']);191 //echo '<pre>';print_r($data); exit();192 $this->view("header", "");193 $this->view("navbar", "");194 $this->view("publicaciones", $datosUsuario);195 $dir_o = $direccionModel->getById($publicacion->id_direccion_origen);196 $dir_o = array(197 'calle' => $dir_o->calle,198 'numero' => $dir_o->numero,199 'piso' => $dir_o->piso,200 'depto' => $dir_o->depto,201 'descripcion' => $dir_o->descripcion, 202 'id_provincia' => $dir_o->id_provincia,203 'id_ciudad' => $dir_o->id_ciudad,204 'provincia' => $provinciaModel->getById($dir_o->id_provincia)->nombre,205 'ciudad' => $ciudadModel->getById($dir_o->id_ciudad)->nombre206 );207 $dir_d = $direccionModel->getById($publicacion->id_direccion_destino);208 $dir_d = array(209 'calle' => $dir_d->calle,210 'numero' => $dir_d->numero,211 'piso' => $dir_d->piso,212 'depto' => $dir_d->depto,213 'descripcion' => $dir_d->descripcion, 214 'id_provincia' => $dir_d->id_provincia,215 'id_ciudad' => $dir_d->id_ciudad,216 'provincia' => $provinciaModel->getById($dir_d->id_provincia)->nombre,217 'ciudad' => $ciudadModel->getById($dir_d->id_ciudad)->nombre218 );219 // $comentarios = (array)$comentarioModel->getByAsArray('id_publicacion', $publicacion->id);220 $comentarios = (array)$comentarioModel->getComentariosPublicacion($publicacion->id);221 // echo '<pre>'; print_r($comentarios); exit();222 for ($i = 0; $i < count($comentarios); $i++){223 $usuario = $usuarioModel->getById($comentarios[$i]['id_usuario']);224 $comentarios[$i]['usuario'] = $usuario->nombre;225 $comentarios[$i]['usuario_avatar'] = $usuario->avatar;226 if (!empty($comentarios[$i]['id_usuario_respuesta']))227 $comentarios[$i]['usuario_respuesta'] = $usuarioModel->getById($comentarios[$i]['id_usuario_respuesta'])->nombre; 228 }229 //echo '<pre>'; print_r($comentarios); exit();230 // $postulantes = $postulacionModel->getByAsArray('id_publicacion', $publicacion->id);231 $data = array(232 'publicacion' => (array)$publicacion,233 'dir_o' => $dir_o,234 'dir_d' => $dir_d,235 'usuario' => (array)($usuarioModel->getById($publicacion->id_usuario)),236 'comentarios' => $comentarios237 // 'postulantes' => $postulantes238 );239 $this->view("publicacion", $data);240 $this->view("footer", "");241 } else {242 $this->redirect('publicacion', 'inicio');243 }244 }245 public function confirmarEnvio(){246 session_start();247 $envioModel = new EnvioModel();248 $id_envio = $_POST['fce_id_envio'];249 $calificacion = $_POST['fce_valoracion'];250 $comentario = !empty($_POST['fce_comentario']) ? $_POST['fce_comentario'] : "Sin comentario.";251 $existente = $envioModel->getByIdAsArray($id_envio);252 $data = array();253 if ($_POST['fce_confirmacion_responsable'] == 1 && $_POST['fce_confirmacion_solicitante'] == 0){254 $data = array(255 'confirmacion_responsable' => $_POST['fce_confirmacion_responsable'],256 'calificacion_responsable' => $calificacion,257 'comentario_responsable' => $comentario258 );259 if ($existente['confirmacion_solicitante'] == 1){260 $data['fecha'] = date("Y-m-d");261 $data['hora'] = date("h:i:sa");262 }263 } else if ($_POST['fce_confirmacion_responsable'] == 0 && $_POST['fce_confirmacion_solicitante'] == 1){264 $data = array(265 'confirmacion_solicitante' => $_POST['fce_confirmacion_solicitante'],266 'calificacion_solicitante' => $calificacion,267 'comentario_solicitante' => $comentario268 );269 if ($existente['confirmacion_responsable'] == 1){270 $data['fecha'] = date("Y-m-d");271 $data['hora'] = date("h:i:sa");272 }273 }274 $envioModel->modificacion($id_envio, $data);275 $this->redirect('usuario','perfil','&id_usuario='.$_SESSION['id']);276 }277 public function comentar(){278 session_start();279 date_default_timezone_set("America/Argentina/Buenos_Aires");280 $cm = new ComentarioModel();281 $data = array(282 'id_publicacion' => $_POST['fc_id_publicacion'],283 'id_usuario' => $_POST['fc_id_usuario'],284 'id_usuario_respuesta' => (isset($_POST['fc_id_usuario_respuesta'])) ? $_POST['fc_id_usuario_respuesta'] : NULL,285 'texto' => (isset($_POST['fc_id_usuario_respuesta'])) ? $_POST['fc_respuesta'] : $_POST['fc_comentario']/*,286 'fecha' => date("Y/m/d"),287 'hora' => date("H:i:s")*/288 );289 $alta = $cm->insert($data);290 if (!$alta)291 echo "Error: ".Conectar::$con->error;292 else293 $this->redirect("Publicacion", "publicacion", "&id_publicacion=".$_POST['fc_id_publicacion']);294 }295 public function postularse(){ // VERIFICAR QUE YA NO EXISTA UNA POSTULACION DE ESE USUARIO EN ESA PUBLICACION (EDITAR SI YA EXISTE??)296 session_start();297 $pm = new PostulacionModel();298 $data = array(299 'id_usuario' => $_SESSION['id'],300 'id_publicacion' => $_POST['fp_id_publicacion'],301 'id_vehiculo' => $_POST['fp_id_vehiculo'],302 'precio' => $_POST['fp_precio']303 );304 if ($existente = $pm->getPostulacionUsuarioPublicacion($_SESSION['id'], $_POST['fp_id_publicacion'])){305 $data['id'] = $existente['id'];306 $modificacion = $pm->modificacion($existente['id'], $data);307 if (!$modificacion)308 echo "Error: ".Conectar::$con->error;309 else310 $this->redirect("Publicacion", "publicacion", "&id_publicacion=".$_POST['fp_id_publicacion']);311 } else {312 $alta = $pm->insert($data);313 if (!$alta)314 echo "Error: ".Conectar::$con->error;315 else316 $this->redirect("Publicacion", "publicacion", "&id_publicacion=".$_POST['fp_id_publicacion']);317 }318 }319 // public function comentar(){ PROBANDO SI VALE LA PENA CON AJAX O NO320 // session_start();321 // date_default_timezone_set("America/Argentina/Buenos_Aires");322 323 // $cm = new ComentarioModel();324 // // $usuarioModel = new UsuarioModel();325 // $data = array(326 // 'id_publicacion' => $_POST['fc_id_publicacion'],327 // 'id_usuario' => $_POST['fc_id_usuario'],328 // 'id_usuario_respuesta' => (isset($_POST['fc_id_usuario_respuesta'])) ? $_POST['fc_id_usuario_respuesta'] : NULL,329 // 'texto' => $_POST['fc_texto'],330 // 'fecha' => date("Y/m/d"),331 // 'hora' => date("H:i:s")332 // );333 // $alta = $cm->insert($data);334 // // $usuario = $usuarioModel->getById($_POST['fc_id_usuario']);335 // // $data['usuario_avatar'] = $usuario->avatar;336 // // $data['usuario'] = $usuario->nombre;337 // // $data['id'] = Conectar::$con->insert_id;338 // if (!$alta)339 // echo "Error: ".Conectar::$con->error;340 // else341 // $this->redirect('publicacion', 'inicio');342 // // if(!$alta)343 // // echo json_encode("Error: ".Conectar::$con->error);344 // // else345 // // echo json_encode($data);346 // }347 public function nuevaPublicacion(){348 session_start();349 if (!isset($_SESSION['id']))350 $this->redirect('publicacion', 'index');351 $usuarioModel = new UsuarioModel();352 $datosUsuario = $usuarioModel->getDatosEnvios($_SESSION['id']);353 $datosUsuario['publicaciones_disponibles'] = $usuarioModel->getPublicacionesDisponibles($_SESSION['id'], $datosUsuario['reputacion'])['nro'];354 $this->view("header", "");355 $this->view("navbar", "");356 $this->view("formPublicacion", $datosUsuario);357 $this->view("footer", "");358 }359 public function buscarPublicaciones(){360 $this->view("header", "");361 $this->view("navbar", "");362 $this->view("buscarPublicaciones", "");363 $this->view("footer", "");364 }365 public function crear(){366 session_start();367 $publicacion = new PublicacionModel();368 $dir = new DireccionModel();369 // Ubicacion de origen370 $data_dir_origen = array(371 'id_provincia' => $_POST['fdo_provincia'],372 'id_ciudad' => $_POST['fdo_ciudad'], 373 'calle' => $_POST['fdo_calle'], 374 'numero' => $_POST['fdo_numero'], 375 'piso' => $_POST['fdo_piso'], 376 'depto' => $_POST['fdo_depto'], 377 'descripcion' => $_POST['fdo_descripcion']378 );379 // Ubicacion de destino380 $data_dir_destino = array(381 'id_provincia' => $_POST['fdd_provincia'],382 'id_ciudad' => $_POST['fdd_ciudad'], 383 'calle' => $_POST['fdd_calle'], 384 'numero' => $_POST['fdd_numero'], 385 'piso' => $_POST['fdd_piso'], 386 'depto' => $_POST['fdd_depto'], 387 'descripcion' => $_POST['fdd_descripcion']388 );389 $alta_origen = $dir->insert($data_dir_origen);390 $id_origen = Conectar::$con->insert_id;391 $alta_destino = $dir->insert($data_dir_destino);392 $id_destino = Conectar::$con->insert_id;393 394 $publicacion->setIdUsuario($_SESSION['id']);395 $publicacion->setIdDireccionOrigen($id_origen);396 $publicacion->setIdDireccionDestino($id_destino);397 $publicacion->setTipoVehiculo ($_POST['fp_tipo_vehiculo']);398 $publicacion->setTitulo ($_POST['fp_titulo']);399 $publicacion->setFechaSalida ($_POST['fp_fecha_salida']);//date("Y-m-d"));400 $publicacion->setHoraSalida ($_POST['fp_hora_salida']);//date("h:i:sa"));401 $publicacion->setPeso ($_POST['fp_medida_peso']);402 $publicacion->setMedidaAlto ($_POST['fp_medida_alto']);403 $publicacion->setMedidaLargo ($_POST['fp_medida_largo']);404 $publicacion->setMedidaAncho ($_POST['fp_medida_ancho']);405 $publicacion->setDescripcion ($_POST['fp_descripcion']);406 $data = array(407 'id_usuario' => $publicacion->getIdUsuario(), 408 'id_direccion_origen' => $publicacion->getIdDireccionOrigen(), 409 'id_direccion_destino' => $publicacion->getIdDireccionDestino(), 410 'tipo_vehiculo' => $publicacion->getTipoVehiculo(), 411 'titulo' => $publicacion->getTitulo(), 412 'fecha_salida' => $publicacion->getFechaSalida(), 413 'hora_salida' => $publicacion->getHoraSalida(), 414 'peso' => $publicacion->getPeso(), 415 'medida_alto' => $publicacion->getMedidaAlto(), 416 'medida_largo' => $publicacion->getMedidaLargo(), 417 'medida_ancho' => $publicacion->getMedidaAncho(), 418 'descripcion' => $publicacion->getDescripcion()419 );420 $alta = $publicacion->insert($data);421 if ($alta)422 $this->redirect("Publicacion", "publicacion", "&id_publicacion=".Conectar::$con->insert_id);423 else424 echo "Error: ".Conectar::$con->error;425 }426 public function confirmarPostulante(){427 session_start();428 $envioModel = new EnvioModel();429 $publicacionModel = new PublicacionModel();430 $postulacionModel = new PostulacionModel();431 $envioModel->setIdPostulacion($_POST['fcp_id_postulacion']);432 $alta = $envioModel->alta();433 $publicacionModel->cambiarEstado($postulacionModel->getById($envioModel->getIdPostulacion())->id_publicacion, 1);434 $postulacionModel->cambiarEstado($postulacionModel->getById($envioModel->getIdPostulacion())->id, 1);435 if ($alta){436 // Confirmacion exitosa437 $_SESSION['log'] = "Confirmado el envio";438 $this->redirect('usuario', 'perfil', '&id_usuario='.$_SESSION['id']);439 //$this->redirect("Publicacion", "publicacion", "&id_publicacion=".$postulacionModel->getById($envioModel->getIdPostulacion())->id_publicacion);440 } else {441 // Error: Falló la confirmación442 $_SESSION['alerta'] = "Error: Falló la confirmación - ".Conectar::$con->error;443 }444 }445 public function eliminarPostulacion(){446 session_start();447 $postulacionModel = new PostulacionModel();448 $id = $_POST['fe_id_postulacion'];449 $postulacionModel->cambiarEstado($id, 2);450 $this->redirect('usuario', 'perfil', "&id_usuario=".$_SESSION['id']);451 }452 public function eliminarPublicacion(){453 session_start();...

Full Screen

Full Screen

CommentController.php

Source:CommentController.php Github

copy

Full Screen

...28 */29 public function comment(Request $request)30 {31 $data = $request->all();32 $me = MemberManager::getById($data['userid']);33 if (checkParam($data, ['item_mid', 'item_id', 'content'])) {34 $comment = CommentManager::createObject();35 $comment = CommentManager::setComment($comment, $data);36 $comment = CommentManager::setUserInfo($comment, $me);37 38 $item = null;39 //获得被评论的信息40 if ($data['item_mid'] == 5) {41 //供应42 $item = SellManager::getById($data['item_id']);43// $item=5;44 } elseif ($data['item_mid'] == 6) {45 //求购46 $item = BuyManager::getById($data['item_id']);47 } elseif ($data['item_mid'] == 21) {48 //资讯49 $item = ArticleManager::getById($data['item_id']);50// } elseif ($data['item_mid'] == 88) {51// //求购52// $item = FJMYManager::getById($data['item_id']);53 }54 if ($item) {55 $comment = CommentManager::setItemInfo($comment, $item);56 } else {57 return ApiResponse::makeResponse(false, "参数错误", ApiResponse::MISSING_PARAM);58 }59 60 $comment->save();61 $user = MemberManager::getByUsername($comment->username);62 63 //发送模版消息64 $openid = MemberManager::getByUsername($item->username);65 $templateid = MessageController::$comment_template_id;66 $page = 'pages/particulars/particulars?mid=' . $data['item_mid'] . '&id=' . $data['item_id'];67 $formid = $item->formId;68 $data_arr = array(69 'keyword1' => array("DATA" => $comment->content),70 'keyword2' => array("DATA" => $me->truename),71 'keyword3' => array("DATA" => date('Y-m-d'))72 );73 MessageController::sendWXTemplateMessage($openid, $templateid, $page, $formid, $data_arr);74 if ($user)75 $comment->businesscard = BussinessCardController::getByUserid($user->userid, $me);76 return ApiResponse::makeResponse(true, $comment, ApiResponse::SUCCESS_CODE);77 } else {78 return ApiResponse::makeResponse(false, "缺少参数", ApiResponse::MISSING_PARAM);79 }80 81 }82 83 84 /*85 * 点赞功能86 *87 * mid=6已完成,等待补完mid=588 *89 * 2018/7/1290 */91 public static function agree(Request $request)92 {93 $data = $request->all();94 $user = MemberManager::getById($data['userid']);95 //检验参数96 if (checkParam($data, ['item_mid', 'item_id'])) {97 $ret = "请求成功";98 $item = null;99 //获得被评论的信息100 if ($data['item_mid'] == 2) {101 $item = CompanyManager::getById($data['item_id']);102 } elseif ($data['item_mid'] == 5) {103 //供应104 $item = SellManager::getById($data['item_id']);105// $item=5;106 } elseif ($data['item_mid'] == 6) {107 //求购108 $item = BuyManager::getById($data['item_id']);109 } elseif ($data['item_mid'] == 21) {110 //资讯111 $item = ArticleManager::getById($data['item_id']);112// } elseif ($data['item_mid'] == 88) {113// //求购114// $item = FJMYManager::getById($data['item_id']);115 }116 $agree1 = AgreeManager::getByCon(117 ['item_mid' => [$data['item_mid']],118 'item_id' => [$data['item_id']],119 'username' => [$user->username]120 ])->first();121 if ($agree1) {122 if ($item && checkParam($data, ['cancle'])) {123 $agree1->delete();124 $item->agree--;125 $item->save();126 return ApiResponse::makeResponse(true, "您取消了点赞", ApiResponse::SUCCESS_CODE);127 }128 129 return ApiResponse::makeResponse(false, "您已经点过赞了", ApiResponse::MISSING_PARAM);130 }131 if ($item) {132 $agree = AgreeManager::createObject();133 $agree = AgreeManager::setAgree($agree, $data, $item);134 $agree = AgreeManager::setUserInfo($agree, $user);135 $agree->addtime = time();136 $item->agree++;137 $agree->save();138 $item->save();139 140 } else {141 return ApiResponse::makeResponse(false, "参数错误", ApiResponse::MISSING_PARAM);142 }143 return ApiResponse::makeResponse(true, $item, ApiResponse::SUCCESS_CODE);144 145 } else {146 return ApiResponse::makeResponse(false, "缺少参数", ApiResponse::MISSING_PARAM);147 }148 }149 150 public static function agreeStatus(Request $request)151 {152 $data = $request->all();153 $user = MemberManager::getById($data['userid']);154 //检验参数155 if (checkParam($data, ['items'])) {156 $ret = [];157 $items = explode(',', $data['items']);158 foreach ($items as $item) {159 array_push($ret,160 AgreeManager::getByCon(161 ['item_mid' => [explode(':', $item)[0]],162 'item_id' => [explode(':', $item)[1]],163 'username' => [$user->username]164 ]165 )->first() ? true : false);166 }167 168 return ApiResponse::makeResponse(true, $ret, ApiResponse::SUCCESS_CODE);169 170 } else {171 return ApiResponse::makeResponse(false, "缺少参数", ApiResponse::MISSING_PARAM);172 }173 }174 175 public static function favorite(Request $request)176 {177 $data = $request->all();178 $user = MemberManager::getById($data['userid']);179 180 //检验参数181 if (checkParam($data, ['mid', 'tid'])) {182 $ret = "收藏成功";183 $item = null;184 //获得被评论的信息185 if ($data['mid'] == 2) {186 $item = CompanyManager::getById($data['tid']);187 } elseif ($data['mid'] == 5) {188 //供应189 $item = SellManager::getById($data['tid']);190// $item=5;191 } elseif ($data['mid'] == 6) {192 //求购193 $item = BuyManager::getById($data['tid']);194 } elseif ($data['mid'] == 21) {195 //资讯196 $item = ArticleManager::getById($data['tid']);197// } elseif ($data['mid'] == 88) {198// //求购199// $item = FJMYManager::getById($data['tid']);200 }201 202 if ($item) {203 $favorite = FavoriteManager::getByCon(['mid' => $data['mid'],204 'tid' => [$data['tid']],205 'userid' => [$data['userid']]206 ])->first();207 208 if (array_key_exists('cancle', $data)) {209 if ($favorite) {210 $favorite->delete();211 $item->favorite--;212 $item->save();213 return ApiResponse::makeResponse(true, "取消成功", ApiResponse::SUCCESS_CODE);214 } else {215 return ApiResponse::makeResponse(false, "没有关注记录", ApiResponse::UNKNOW_ERROR);216 }217 } else if ($favorite) {218 return ApiResponse::makeResponse(false, "已收藏", ApiResponse::UNKNOW_ERROR);219 }220 $favorite = $favorite ? $favorite : FavoriteManager::createObject();221 $favorite = FavoriteManager::setFavorite($favorite, $data);222 $item->favorite++;223 $favorite->save();224 $item->save();225 } else {226 return ApiResponse::makeResponse(false, "参数错误", ApiResponse::MISSING_PARAM);227 }228 229 return ApiResponse::makeResponse(true, $ret, ApiResponse::SUCCESS_CODE);230 231 } else {232 return ApiResponse::makeResponse(false, "缺少参数", ApiResponse::MISSING_PARAM);233 }234 }235 236 public static function favoriteStatus(Request $request)237 {238 $data = $request->all();239 $user = MemberManager::getById($data['userid']);240 //检验参数241 if (checkParam($data, ['items'])) {242 $ret = [];243 $items = explode(',', $data['items']);244 foreach ($items as $item) {245 array_push($ret,246 FavoriteManager::getByCon(247 ['mid' => [explode(':', $item)[0]],248 'tid' => [explode(':', $item)[1]],249 'userid' => [$user->userid]250 ]251 )->first() ? true : false);252 }253 254 return ApiResponse::makeResponse(true, $ret, ApiResponse::SUCCESS_CODE);255 256 } else {257 return ApiResponse::makeResponse(false, "缺少参数", ApiResponse::MISSING_PARAM);258 }259 }260 261 public static function myFavorite(Request $request)262 {263 $data = $request->all();264 $user = MemberManager::getById($data['userid']);265 $con = ['userid' => [$data['userid']]];266 if (array_key_exists('mid', $data)) {267 $con['mid'] = [$data['mid']];268 }269 $myFavorites = FavoriteManager::getByCon($con, true, ['itemid', 'desc']);270 foreach ($myFavorites as $favorite) {271 switch ($favorite->mid) {272 case '2':273 $item = BussinessCardController::getByUserid($favorite->tid, $user);274 $favorite->item = $item;275 break;276 case '5':277 $item = SellManager::getById($favorite->tid);278 if ($item) {279 $item = SellManager::getInfo($item, ['content', 'userinfo', 'tags']);280 $item = SellManager::getAgreeAndFavorite($item, $user);281 }282 $favorite->item = $item;283 break;284 case '6':285 $item = BuyManager::getById($favorite->tid);286 if ($item) {287 $item = BuyManager::getInfo($item, ['content', 'userinfo', 'tags']);288 $item = BuyManager::getAgreeAndFavorite($item, $user);289 }290 $favorite->item = $item;291 break;292 case '21':293 $favorite->item = ArticleManager::getById($favorite->tid);294 break;295// case '88':296// $item = FJMYManager::getById($favorite->tid);297// if ($item) {298// $item = FJMYManager::getInfo($item, ['content', 'userinfo', 'tags']);299// $item = FJMYManager::getAgreeAndFavorite($item, $user);300// }301// $favorite->item = $item;302// break;303 default:304 break;305 }306 }307 return ApiResponse::makeResponse(true, $myFavorites, ApiResponse::SUCCESS_CODE);308 }309 310 public static function reply(Request $request)311 {312 $data = $request->all();313 $user = MemberManager::getById($data['userid']);314 //检验参数315 if (checkParam($data, ['itemid', 'reply'])) {316 $comment = CommentManager::getById($data['itemid']);317 if ($comment->item_username != $user->username) {318 return ApiResponse::makeResponse(false, "只能回复自己发布的信息!", ApiResponse::UNKNOW_ERROR);319 }320 321 $comment->reply = $data['reply'];322 $comment->replytime = time();323 $comment->replyer = $user->username;324 $comment->save();325 326 $ret = "回复成功";327 328 return ApiResponse::makeResponse(true, $ret, ApiResponse::SUCCESS_CODE);329 330 } else {331 return ApiResponse::makeResponse(false, "缺少参数", ApiResponse::MISSING_PARAM);332 }333 }334 335 public static function CommentToMe(Request $request)336 {337 $data = $request->all();338 $user = MemberManager::getById($data['userid']);339 //检验参数340 if (true) {341 $comments = CommentManager::getByReceiver($user);342 foreach ($comments as $comment) {343 $_user = MemberManager::getByUsername($comment->username);344 if ($_user)345 $comment->user_card = BussinessCardController::getByUserid($_user->userid);346 347 $replyer = MemberManager::getByUsername($comment->replyer);348 if ($replyer)349 $comment->replyer_card = BussinessCardController::getByUserid($replyer->userid);350 351 $comment->item = InfoManager::getById($comment->item_mid, $comment->item_id);352 }353 return ApiResponse::makeResponse(true, $comments, ApiResponse::SUCCESS_CODE);354 } else {355 return ApiResponse::makeResponse(false, "缺少参数", ApiResponse::MISSING_PARAM);356 }357 }358 359 public static function MyComments(Request $request)360 {361 $data = $request->all();362 $user = MemberManager::getById($data['userid']);363 //检验参数364 if (true) {365 366 $comments = CommentManager::getBySender($user);367 foreach ($comments as $comment) {368 $_user = MemberManager::getByUsername($comment->username);369 if ($_user)370 $comment->user_card = BussinessCardController::getByUserid($_user->userid);371 372 $replyer = MemberManager::getByUsername($comment->replyer);373 if ($replyer)374 $comment->replyer_card = BussinessCardController::getByUserid($replyer->userid);375 376 $comment->item = InfoManager::getById($comment->item_mid, $comment->item_id);377 }378 return ApiResponse::makeResponse(true, $comments, ApiResponse::SUCCESS_CODE);379 } else {380 return ApiResponse::makeResponse(false, "缺少参数", ApiResponse::MISSING_PARAM);381 }382 }383}...

Full Screen

Full Screen

Services.php

Source:Services.php Github

copy

Full Screen

...111 $client_balance = 0;112 $res = array();113 $balances = $this->ViewList(self::TABLE_CLIENT_BALANCE_LOG,"client_id = ".$request->get("client_id"));114 foreach ($balances as $balance) {115 $balance['patient'] = $this->getById(self::TABLE_PATIENTS,$balance['patient_id']);116 if ($firstElement) {117 $firstElement = false;118 $client_balance = $balance['amount'];119 } else {120 if ($balance['type'] == 1) {121 $client_balance += $balance['amount'];122 } else {123 $client_balance -= $balance['amount'];124 }125 }126 $balance['balance'] = $client_balance;127 $res[] = $balance;128 }129 return $res;...

Full Screen

Full Screen

getById

Using AI Code Generation

copy

Full Screen

1$object = new data();2$object->getById(1);3$object = new data();4$object->getById(2);5$object = new data();6$object->getById(3);7$object = new data();8$object->getById(4);9$object = new data();10$object->getById(5);11$object = new data();12$object->getById(6);13$object = new data();14$object->getById(7);15$object = new data();16$object->getById(8);17$object = new data();18$object->getById(9);19$object = new data();20$object->getById(10);21$object = new data();22$object->getById(11);23$object = new data();24$object->getById(12);25$object = new data();26$object->getById(13);27$object = new data();28$object->getById(14);29$object = new data();30$object->getById(15);31$object = new data();32$object->getById(16);

Full Screen

Full Screen

getById

Using AI Code Generation

copy

Full Screen

1$myData = new Data();2$myData->getById(2);3$myData = new Data();4$myData->getById(2);5$myData = new Data();6$myData->getById(2);7include_once("data.php");8$myData = new Data();9$myData->getById(2);10include_once("data.php");11$myData = new Data();12$myData->getById(2);13include_once("data.php");14$myData = new Data();15$myData->getById(2);

Full Screen

Full Screen

getById

Using AI Code Generation

copy

Full Screen

1$obj = new data();2$obj->getById(1);3echo $obj->name;4echo $obj->email;5echo $obj->phone;6echo $obj->address;7$obj = new data();8$obj->getById(2);9echo $obj->name;10echo $obj->email;11echo $obj->phone;12echo $obj->address;13$obj = new data();14$obj->getById(3);15echo $obj->name;16echo $obj->email;17echo $obj->phone;18echo $obj->address;19$obj = new data();20$obj->getById(4);21echo $obj->name;22echo $obj->email;23echo $obj->phone;24echo $obj->address;25$obj = new data();26$obj->getById(5);27echo $obj->name;28echo $obj->email;29echo $obj->phone;30echo $obj->address;31$obj = new data();32$obj->getById(6);33echo $obj->name;34echo $obj->email;35echo $obj->phone;36echo $obj->address;37$obj = new data();38$obj->getById(7);39echo $obj->name;40echo $obj->email;41echo $obj->phone;42echo $obj->address;43$obj = new data();44$obj->getById(8);45echo $obj->name;46echo $obj->email;47echo $obj->phone;48echo $obj->address;49$obj = new data();50$obj->getById(9);51echo $obj->name;52echo $obj->email;53echo $obj->phone;54echo $obj->address;55$obj = new data();56$obj->getById(10);57echo $obj->name;

Full Screen

Full Screen

getById

Using AI Code Generation

copy

Full Screen

1require_once("data.php");2$id = 1;3$d = new Data();4$student = $d->getById($id);5echo $student->name;6echo $student->email;7echo $student->mobile;8{9 public $id;10 public $name;11 public $email;12 public $mobile;13}14{15 public function getById($id)16 {17 $student = new Student();18 $student->id = 1;19 $student->name = "John";

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger getById code on LambdaTest Cloud Grid

Execute automation tests with getById on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful