Ejemplo n.º 1
0
 function login(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $data = json_decode($request->getBody(), true);
     $cont = 0;
     $std = 0;
     $roles = array();
     $dataCliente = Cliente::select("email", "nombres", "apellidos")->where('email', '=', $data['usuario'])->where('pass', '=', $data['pass'])->first();
     if ($dataCliente != null) {
         $cont++;
         array_push($roles, "cliente");
     }
     $dataEmpresa = Empresa::select("email", "nombre", "foto")->where('email', '=', $data['usuario'])->where('pass', '=', $data['pass'])->first();
     if ($dataEmpresa != null) {
         $cont++;
         array_push($roles, "empresa");
     }
     $dataUsuario = Usuario::select("id", "nombres", "apellidos", "idSucursal", "idCategoria")->where('id', '=', $data['usuario'])->where('pass', '=', $data['pass'])->first();
     if ($dataUsuario != null) {
         $cont++;
         array_push($roles, "usuario");
     }
     if ($cont > 0) {
         $response = $response->withStatus(200);
         $std = 1;
     } else {
         $response = $response->withStatus(404);
     }
     $response->getBody()->write(json_encode(array("std" => $std, "roles" => $roles)));
     return $response;
 }
Ejemplo n.º 2
0
 function empresaactivas(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $data = Empresa::select('*')->where('estado', '=', 'ACTIVO')->get();
     if (count($data) == 0) {
         $response = $response->withStatus(404);
     }
     $response->getBody()->write($data);
     return $response;
 }