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


PHP Car::findFirst方法代码示例

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


在下文中一共展示了Car::findFirst方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: applicationsAction

 public function applicationsAction()
 {
     $date = new DateTime("now");
     if ($this->request->isPost() and $this->request->isAjax()) {
         $start_from = $this->request->getPost('start_from', 'int');
         $type = $this->request->getPost('type', 'int');
         if ($type == 1) {
             $apps = Application::find(array('conditions' => 'confirmed = 0 and term >= ?1', 'order' => 'term DESC', 'limit' => '5', 'offset' => $start_from, 'bind' => array(1 => $date->format('Y.m.d'))));
         } else {
             if ($type == 2) {
                 $apps = Application::find(array('conditions' => 'confirmed = 1 and term >= ?1', 'order' => 'term DESC', 'limit' => '5', 'offset' => $start_from, 'bind' => array(1 => $date->format('Y.m.d'))));
             } else {
                 if ($type == 3) {
                     $apps = Application::find(array('conditions' => 'confirmed = 1 and term < ?1', 'order' => 'term DESC', 'limit' => '5', 'offset' => $start_from, 'bind' => array(1 => $date->format('Y.m.d'))));
                 } else {
                     $apps = array();
                 }
             }
         }
         $services = array();
         $users = array();
         foreach ($apps as $key => $app) {
             $str = "";
             $a_ss = ApplicationService::find(array('conditions' => 'application_id = ?1', 'bind' => array(1 => $app->id)));
             foreach ($a_ss as $a_s) {
                 $service = Service::findFirst(array('conditions' => 'id = ?1', 'bind' => array(1 => $a_s->service_id)));
                 $str .= $service->name . ', ';
             }
             $services[$key] = substr($str, 0, -2) . '.';
             $car = Car::findFirst(array('conditions' => 'number = ?1', 'bind' => array(1 => $app->car)));
             $users[$key] = User::findFirst(array('conditions' => 'id = ?1', 'bind' => array(1 => $car->owner)));
         }
         if (count($apps) > 0) {
             $view = clone $this->view;
             $view->start();
             $view->setRenderLevel(View::LEVEL_ACTION_VIEW);
             $view->setParamToView('apps', $apps);
             $view->setParamToView('type', $type);
             $view->setParamToView('services', $services);
             $view->setParamToView('users', $users);
             $view->render('admin', 'applications');
             $view->finish();
             $content = $view->getContent();
             $this->view->disable();
             $status = 200;
             $description = 'OK';
             $headers = array();
             $contentType = 'application/json';
             $content = json_encode($content);
             $response = new \Phalcon\Http\Response();
             $response->setStatusCode($status, $description);
             $response->setContentType($contentType, 'UTF-8');
             $response->setContent($content);
             foreach ($headers as $key => $value) {
                 $response->setHeader($key, $value);
             }
             return $response;
         } else {
             return 0;
         }
     }
 }
开发者ID:Flerki,项目名称:CarRepairTotal,代码行数:62,代码来源:AdminController.php

示例2: hasDone

 public static function hasDone($uid)
 {
     $car = Car::findFirst("uid={$uid}");
     if (!$car) {
         return false;
     }
     $advises = Advise::getAdvisesByUid($uid, Advise::STATUS_UNDO, 'car');
     return $advises ? false : true;
 }
开发者ID:Crocodile26,项目名称:php-1,代码行数:9,代码来源:Car.php

示例3: viewAction

 public function viewAction($id = null)
 {
     if (!is_null($id) and is_numeric($id)) {
         $car = Car::findFirst("id = " . $id);
         if (!$car) {
             return $this->dispatcher->forward(["controller" => "index", "action" => "index"]);
         }
         $this->view->car = $car;
     } else {
         return $this->dispatcher->forward(["controller" => "index", "action" => "index"]);
     }
 }
开发者ID:magnuspwhite,项目名称:JDI-Task,代码行数:12,代码来源:CarController.php

示例4: applyAction

 public function applyAction()
 {
     if ($this->request->isPost()) {
         $user = $this->getAuth();
         $new_car = $this->request->getPost('new_car');
         if ($new_car == 0) {
             $car = Car::findFirst(array('conditions' => 'number = ?1', 'bind' => array(1 => $this->request->getPost('choose-car'))));
         } else {
             $car = new Car();
             $car->number = $this->request->getPost('number');
             $car->brand = $this->request->getPost('brand');
             $car->model = $this->request->getPost('model');
             $car->owner = $user['user_id'];
             if (!$car->save()) {
                 message($this, "d", "Данные об автомобиле указаны неверно");
                 return $this->response->redirect("applyForService");
             }
         }
         if ($car) {
             $date = $this->request->getPost('date');
             $time = $this->request->getPost('time');
             $apps = Application::find(array('conditions' => 'term = ?1', 'bind' => array(1 => $date)));
             if ($date) {
                 if ($time) {
                     if (count($apps) < 4 * 20) {
                         $services = $this->request->getPost('services');
                         if (count($services) > 0) {
                             $app = new Application();
                             $app->car = $car->number;
                             $app->term = $date . ' ' . $time;
                             $app->confirmed = 0;
                             $app->manager = NULL;
                             if ($app->save()) {
                                 foreach ($services as $service) {
                                     $as = new ApplicationService();
                                     $as->application_id = $app->id;
                                     $as->service_id = $service;
                                     if (!$as->save()) {
                                         message($this, "d", "Ошибка при сохранении выбранной услуги");
                                         return $this->response->redirect("applyForService");
                                     }
                                 }
                                 //todo! Обработка поля с доп. информацией
                                 message($this, "s", "Заявка отправлена. В ближайшее время наш менеджер свяжется с Вами для ее подтверждения");
                                 return $this->response->redirect("cabinet");
                             } else {
                                 message($this, "d", "Ошибка при сохранении заявки");
                                 foreach ($app->getMessages() as $message) {
                                     message($this, "d", "Ошибка: " . $message->getMessage() . " в поле " . $message->getField() . ". Тип: " . $message->getType());
                                 }
                                 return $this->response->redirect("applyForService");
                             }
                         } else {
                             message($this, "d", "Минимум одна услуга должна быть выбрана");
                             return $this->response->redirect("applyForService");
                         }
                     } else {
                         message($this, "d", "Выбранная дата занята. Пожалуйста, выберите другой день");
                         return $this->response->redirect("applyForService");
                     }
                 } else {
                     message($this, "d", "Время не выбрано!");
                     return $this->response->redirect("applyForService");
                 }
             } else {
                 message($this, "d", "Дата не выбрана!");
                 return $this->response->redirect("applyForService");
             }
         } else {
             message($this, "d", "Автомобиль не найден");
             return $this->response->redirect("applyForService");
         }
     }
 }
开发者ID:Flerki,项目名称:CarRepairTotal,代码行数:74,代码来源:UserController.php

示例5: advise

 public static function advise($uid, $foid, $adviseType, $reason, $loan = false)
 {
     $isLoanSketch = false;
     switch ($adviseType) {
         case 'loansketch':
             $status = \App\LoanStatus::getStatusSketch();
             $oid = User::findFirst("uid={$uid}")->oid;
             $isLoanSketch = true;
             break;
         case 'visit':
             $status = \App\LoanStatus::getStatusCarAssess();
             $oid = Visit::findFirst("uid={$uid}")->oid;
             $isLoanSketch = true;
             break;
         case 'car':
             $status = \App\LoanStatus::getStatusVisit();
             $oid = Car::findFirst("uid={$uid}")->oid;
             $isLoanSketch = true;
             break;
         case 'face':
             $status = \App\LoanStatus::getStatusChecked();
             $oid = Face::findFirst("uid={$uid}")->oid;
             $isLoanSketch = true;
             break;
     }
     if (empty($oid)) {
         return false;
     }
     if ($isLoanSketch) {
         $model = LoanSketch::findFirst("uid={$uid}");
         $model->status = $status;
         $model->update();
     }
     Advise::add($uid, $oid, $foid, $adviseType, $reason);
     return true;
 }
开发者ID:Crocodile26,项目名称:php-1,代码行数:36,代码来源:Loan.php


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