當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Operation::all方法代碼示例

本文整理匯總了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);
 }
開發者ID:HLitmus,項目名稱:WebApp,代碼行數:61,代碼來源:vendor.php

示例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);
 }
開發者ID:HLitmus,項目名稱:WebApp,代碼行數:62,代碼來源:lab.php


注:本文中的Operation::all方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。