public function province() { $result = Province::where('PAK_ID', Input::get('id'))->select('PROVINCE_ID', 'PROVINCE_NAME')->get(); $dropdown = '<option value=""></option>'; foreach ($result as $result) { $dropdown .= '<option value="' . $result->PROVINCE_ID . '">' . $result->PROVINCE_NAME . '</option>'; } return Response::make($dropdown); }
function updatePosition() { $positionList = $this->input->post('positionList'); $idList = $this->input->post('idList'); $locations = new Province(); for ($i = 0; $i < count($idList); $i++) { $locations->where("id", $idList[$i]); $locations->get(); $locations->position = $positionList[$i]; $locations->save(); $locations->clear(); } redirect("admin/locations/listAll/"); }
public function upload_pharmaceuticals_domains() { $pharmacist_domain_class = new PharmacistDomain(); $input = Input::All(); $header = array_shift($input); //retrieve header row $success = true; if (!$this->checkHeader($header, $pharmacist_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($pharmacist_domain_class->getTableName())->delete(); foreach ($input as $row) { try { $row = $this->readRow($row, $header); $province = Province::where("description", "=", $row["province"])->first(); $pharmacist_domain = new PharmacistDomain(array("domain" => $row["domain"], "province" => $province->description, "province_id" => $province->id)); $pharmacist_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)); }