/** * @before _secure, _doctor */ public function profile() { $this->seo(array("title" => "Doctor | Profile", "view" => $this->getLayoutView())); $view = $this->getActionView(); $user = $this->user; $view->set("errors", array()); if (RequestMethods::post("action") == "saveUser") { $phone = RequestMethods::post("phone"); if ($phone && $phone != $user->phone) { $exists = User::first(array("phone = ?" => $phone)); if ($exists) { $view->set("message", "Phone Number already exists!!"); return; } $user->phone = $phone; } $user->name = RequestMethods::post("name"); $user->birthday = RequestMethods::post("birthday"); $user->save(); $this->setUser($user); $return = \Doc::saveRecord($user, $this->doctor); if (is_array($return)) { $view->set("errors", $return); $view->set("message", "Fix the following errors"); } else { $this->setDoctor($return); $view->set("message", "Basic Info saved!!"); } } $locations = Location::all(array("user_id = ?" => $user->id)); if (RequestMethods::post("action") == "saveLocation") { $location = $locations[RequestMethods::post("location_id")]; \Location::saveRecord($user, $location); $view->set("message", "Updated Location"); } if (RequestMethods::post("addLocation")) { $location = \Location::saveRecord($user); $view->set("message", "Added New Location"); $arr = array($location->id => $location); $locations = array_merge($locations, $arr); } $view->set("locations", $locations); $view->set("specialities", self::$_specialities)->set("medicines", array()); }