当前位置: 首页>>代码示例>>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;未经允许,请勿转载。