当前位置: 首页>>代码示例>>PHP>>正文


PHP Location::first方法代码示例

本文整理汇总了PHP中Location::first方法的典型用法代码示例。如果您正苦于以下问题:PHP Location::first方法的具体用法?PHP Location::first怎么用?PHP Location::first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Location的用法示例。


在下文中一共展示了Location::first方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: create

 /**
  * @before _secure, _vendor
  */
 public function create()
 {
     $this->seo(array("title" => "Create runner", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $msg = "";
     $centres = Centre::all(array("organization_id = ?" => $this->organization->id), array("id", "location_id"));
     $upload = function ($key) {
         if (isset($_FILES["image"]["name"][$key])) {
             $file = $_FILES["image"];
             $path = APP_PATH . "/public/assets/uploads/images/";
             $extension = pathinfo($file["name"][$key], PATHINFO_EXTENSION);
             if (!preg_match("/^(jpe?g|gif|png|bmp)\$/", $extension)) {
                 return false;
             }
             $filename = uniqid() . ".{$extension}";
             if (move_uploaded_file($file["tmp_name"][$key], $path . $filename)) {
                 return $filename;
             } else {
                 return FALSE;
             }
         } else {
             return false;
         }
     };
     if (RequestMethods::post("phone")) {
         $phone = RequestMethods::post("phone");
         $name = RequestMethods::post("name");
         $centre_id = RequestMethods::post("centre_id");
         foreach ($phone as $key => $value) {
             if (!empty($value)) {
                 $exist = User::first(array("phone = ?" => $phone[$key]), array("id"));
                 $img = $upload($key);
                 if (!$img) {
                     $msg = 'Not a vaild image';
                 } else {
                     if ($exist) {
                         $msg = 'Phone number already exists';
                     }
                 }
                 if (!$exist && $img) {
                     $user = new User(array("name" => $name[$key], "email" => "", "phone" => $phone[$key], "password" => sha1(rand(100000, 9999999)), "gender" => $gender[$key], "birthday" => "", "live" => true));
                     $user->save();
                     foreach ($centre_id[$key] as $k => $v) {
                         $runner = new Member(array("user_id" => $user->id, "organization_id" => $this->organization->id, "centre_id" => $v, "designation" => "runner", "image" => $img, "live" => true));
                         $runner->save();
                     }
                     $msg = "Runner Created Successfully";
                 } else {
                     $msg .= ", Not all were added";
                 }
             }
         }
         $view->set("message", $msg);
     }
     $locations = array();
     foreach ($centres as $c) {
         $l = Location::first(array("id = ?" => $c->location_id), array("area_id"));
         $a = Area::first(array("id = ?" => $l->area_id), array("name", "id"));
         $data = array("id" => $c->id, "name" => $a->name);
         $data = ArrayMethods::toObject($data);
         $locations[$c->id] = $data;
     }
     $view->set("centres", $locations);
 }
开发者ID:HLitmus,项目名称:WebApp,代码行数:67,代码来源:runner.php

示例3: edit

 /**
  * @before _secure, _school
  */
 public function edit($user_id)
 {
     $this->setSEO(array("title" => "Edit Student Info | School"));
     $view = $this->getActionView();
     $user = User::first(array("id = ?" => $user_id));
     $scholar = Scholar::first(array("user_id = ?" => $user->id));
     if (!$scholar || $scholar->organization_id != $this->organization->id) {
         self::redirect("/404");
     }
     $location = Location::first(array("user_id = ?" => $user->id));
     if (RequestMethods::post("action") == "updateInfo") {
         $user->name = RequestMethods::post("name");
         $user->email = RequestMethods::post("email");
         $user->phone = RequestMethods::post("phone");
         $user->save();
         $location->address = RequestMethods::post("address");
         $location->city = RequestMethods::post("city");
         if ($location->validate()) {
             $location->save();
         }
         $scholar->dob = RequestMethods::post("dob");
         $scholar->roll_no = RequestMethods::post("roll_no");
         if ($scholar->validate()) {
             $scholar->save();
         }
         $view->set("success", "Saved successfully!!");
     }
     $view->set("usr", $user);
     $view->set("scholar", $scholar);
     $view->set("location", $location);
 }
开发者ID:SwiftSchool,项目名称:School,代码行数:34,代码来源:student.php

示例4: display

 /**
  * @before _secure, _vendor
  */
 public function display($id)
 {
     $this->seo(array("title" => "Display Appointments", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $apptmt = Appointment::first(array("id = ?" => $id), array("service_id", "id", "start", "centre_id", "user_id", "location_id"));
     $usr = User::first(array("id = ?" => $apptmt->user_id), array("id", "name", "email", "phone"));
     $job = Job::first(array("appointment_id = ?" => $apptmt->id), array("user_id", "id"));
     $location = Location::first(array("id = ?" => $apptmt->location_id), array("street", "area_id", "city_id"));
     $area = Area::first(array("id = ?" => $location->area_id), array("name"));
     $city = City::first(array("id = ?" => $location->city_id), array("name"));
     if (!$apptmt) {
         $view->set("err", "Invalid ID");
     } else {
         $view->set("usr", $usr);
         $view->set("job", $job);
         $view->set("e", $apptmt);
         $view->set("address", $location->street . ", " . $area->name . ", " . $city->name);
     }
 }
开发者ID:HLitmus,项目名称:WebApp,代码行数:22,代码来源:appointments.php

示例5: details

 public function details($title, $id = '')
 {
     $organization = Organization::first(array("id = ?" => $id));
     $this->seo(array("title" => $organization->name, "keywords" => $organization->name, "description" => substr(strip_tags($organization->details), 0, 150), "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $centre = Centre::first(array("organization_id = ?" => $id), array("*"), "created", "desc");
     $services = Service::all(array("centre_id = ?" => $centre->id), array("property", "property_id", "charge"));
     $location = Location::first(array("id = ?" => $centre->location_id), array("street", "area_id", "city_id"));
     $area = Area::first(array("id = ?" => $location->area_id), array("name"));
     $city = City::first(array("id = ?" => $location->city_id), array("name"));
     $view->set("centre", $centre);
     $view->set("area", $area);
     $view->set("city", $city);
     $view->set("location", $location);
     $view->set("services", $services);
     $view->set("organization", $organization);
 }
开发者ID:HLitmus,项目名称:WebApp,代码行数:17,代码来源:lab.php

示例6: download

 /**
  * @before _secure, _vendor
  */
 public function download()
 {
     $this->noview();
     $tests = Test::all(array("live = ?" => true), array("title"));
     $centres = Centre::all(array("organization_id = ?" => $this->organization->id), array("location_id"));
     $locations = array();
     foreach ($centres as $centre) {
         $loc = Location::first(array("id = ?" => $centre->location_id), array("city"));
         array_push($locations, $loc->city);
     }
     header('Content-Type: text/csv; charset=utf-8');
     header('Content-Disposition: attachment; filename=medicaltests.csv');
     // create a file pointer connected to the output stream
     $output = fopen('php://output', 'w');
     $first = array("Medical Test");
     $locations = array_unique($locations);
     foreach ($locations as $location) {
         array_push($first, "Price at " . $location);
     }
     fputcsv($output, $first);
     foreach ($tests as $test) {
         $data = array();
         array_push($data, $test->title);
         foreach ($locations as $location) {
             array_push($data, "");
         }
         fputcsv($output, $data);
     }
 }
开发者ID:HLitmus,项目名称:WebApp,代码行数:32,代码来源:medicaltest.php


注:本文中的Location::first方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。