Esempio n. 1
0
 public function postContacto(Request $request)
 {
     $newContact = ["nombre" => $request->nombre, "email" => $request->email, "telefono" => $request->telefono, "mensaje" => $request->mensaje, "estado" => "no_leido", "identidad" => $request->identidad];
     $created = contacto::create($newContact);
     if ($created) {
         $response = Response::json(['success' => true], 200);
     } else {
         $response = Response::json(['success' => false], 400);
     }
     return $response;
 }
Esempio n. 2
0
 public function changeContactState(Request $request)
 {
     $allGood = true;
     $stateUpdate = ["estado" => $request->estado];
     foreach ($request->contactos as $contacto) {
         $contact = contacto::where('id', $contacto)->update($stateUpdate);
         if (!$contact) {
             $allGood = false;
         }
     }
     if ($allGood) {
         $response = Response::json(['success' => true, 'message' => 'Operacion realizada con exito'], 200);
     } else {
         $response = Response::json(['success' => false, 'message' => 'Operacion fallida, error al hacer update'], 400);
     }
     return $response;
 }