Пример #1
0
 public function upload_doctors_domains()
 {
     $doctor_domain_class = new DoctorDomain();
     $input = Input::All();
     $header = array_shift($input);
     //retrieve header row
     $success = true;
     if (!$this->checkHeader($header, $doctor_domain_class->columns())) {
         $success = false;
         $response = "Cabeceras del Excel no coincide con la base de datos.\n                    No se procederá a modificar la base de datos.";
     }
     DB::table($doctor_domain_class->getTableName())->delete();
     foreach ($input as $row) {
         try {
             $row = $this->readRow($row, $header);
             $province = Province::where("description", "=", $row["province"])->first();
             $doctor_domain = new DoctorDomain(array("domain" => $row["domain"], "province" => $province->description, "province_id" => $province->id));
             $doctor_domain->save();
         } catch (Exception $ex) {
             $success = false;
             $response = "Ha habido algún problema cargando el Excel en la base de datos." . "\n" . $ex->getMessage();
         }
     }
     if ($success) {
         $response = "Se ha cargado correctamente el Excel en la base de datos.";
     }
     return Response::json(array("success" => $success, "response" => $response));
 }
Пример #2
0
 public function domain()
 {
     $specialty_id = Input::get("specialty");
     $province_id = Input::get("province");
     $success = true;
     if ($specialty_id == Config::get("constants.SPECIALTY_TYPE.DOCTOR")) {
         $domains = DoctorDomain::where("province_id", "=", $province_id)->get()->toArray();
     } else {
         if ($specialty_id == Config::get("constants.SPECIALTY_TYPE.PHARMACIST")) {
             $domains = PharmacistDomain::where("province_id", "=", $province_id)->get()->toArray();
         } else {
             $success = false;
         }
     }
     return Response::json(array("success" => $success, "domains" => $domains));
 }