本文整理汇总了PHP中Operation::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Operation::all方法的具体用法?PHP Operation::all怎么用?PHP Operation::all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Operation
的用法示例。
在下文中一共展示了Operation::all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: settings
/**
* @before _secure, _vendor
*/
public function settings()
{
$this->seo(array("title" => "Settings", "view" => $this->getLayoutView()));
$view = $this->getActionView();
$centre = Centre::first(array("id = ?" => $this->member->centre_id));
$location = Location::first(array("id = ?" => $centre->location_id));
$area = Area::first(array("id = ?" => $location->area_id));
if (RequestMethods::post("action") == "settings") {
$phone = RequestMethods::post("phone");
$user = $this->user;
$message = null;
if ($phone != $user->phone) {
$exist = User::first(array("phone = ?" => $phone));
if ($exist) {
$message = "Phone number already exists";
} else {
$user->phone = $phone;
}
}
$user->name = RequestMethods::post("name");
$user->save();
$this->setUser($user);
$location = \Location::saveRecord($user, $location);
$phone = RequestMethods::post("cphone");
if ($centre->phone != $phone) {
$exist = Centre::first(array("phone = ?" => $phone));
if ($exist) {
$message = "Landline already exists!!";
} else {
$centre->phone = $phone;
$centre->save();
}
}
if (!$message) {
$message = "Info updated!!";
}
$view->set("message", $message);
}
if (RequestMethods::post("action") == "operations") {
$operations = RequestMethods::post("operations");
foreach ($operations as $key => $value) {
$operation = Operation::first(array("centre_id = ?" => $id, "area_id = ?" => $value));
if (!$operation) {
$operation = new Operation(array("user_id" => $this->user->id, "centre_id" => $id, "organization_id" => $this->organization->id, "area_id" => $value, "live" => 1));
$operation->save();
}
}
}
$ops = Operation::all(array("centre_id = ?" => $id), array("area_id"));
$opa = array();
foreach ($ops as $o) {
$opa[] = $o->area_id;
}
$view->set("centre", $centre);
$view->set("area", $area);
$view->set("location", $location);
$view->set("opa", $opa);
}
示例2: update
/**
* @before _secure, _vendor
*/
public function update($id)
{
$this->seo(array("title" => "Edit Lab", "view" => $this->getLayoutView()));
$view = $this->getActionView();
$centre = Centre::first(array("id = ?" => $id));
if (RequestMethods::get("live")) {
$centre->live = RequestMethods::get("live", 0);
$centre->save();
$this->redirect("/lab/manage");
}
$location = Location::first(array("id = ?" => $centre->location_id));
$areas = Area::all(array("city_id = ?" => $location->city_id), array("name", "id"));
$manager = User::first(array("id = ?" => $this->member->user_id));
if (RequestMethods::post("action") == "medicallab") {
$message = null;
$location->street = RequestMethods::post("street");
$location->area_id = RequestMethods::post("area_id");
$location->city_id = RequestMethods::post("city_id");
if ($location->validate()) {
$location->save();
} else {
$message = "Center location was not saved!!";
}
$phone = RequestMethods::post("phone");
if ($phone != $centre->phone) {
$exist = Center::first(array("phone = ?" => $phone));
if ($exist) {
$message = "Phone number already exists";
} else {
$centre->phone = $phone;
$centre->save();
}
}
if (!$message) {
$message = "Lab info updated!!";
}
$view->set("message", $message);
}
if (RequestMethods::post("action") == "operations") {
$operations = RequestMethods::post("operations");
foreach ($operations as $key => $value) {
$operation = Operation::first(array("centre_id = ?" => $id, "area_id = ?" => $value));
if (!$operation) {
$operation = new Operation(array("user_id" => $this->user->id, "centre_id" => $id, "organization_id" => $this->organization->id, "area_id" => $value, "live" => 1));
$operation->save();
}
}
}
$ops = Operation::all(array("centre_id = ?" => $id), array("area_id"));
$opa = array();
foreach ($ops as $o) {
$opa[] = $o->area_id;
}
$view->set("centre", $centre);
$view->set("manager", $manager);
$view->set("location", $location);
$view->set("areas", $areas);
$view->set("opa", $opa);
}