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


PHP Car::where方法代码示例

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


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

示例1: store

 public function store()
 {
     $limit = 2;
     if (!Input::has('number')) {
         return $this->respondInsufficientPrivileges('No car number');
     }
     $number = Input::get('number');
     $car = Car::where('number', $number)->first();
     if (!$car) {
         return $this->respondNotFound('Car not found');
     }
     $user = $car->user;
     if (!$user) {
         return $this->respondNotFound('User not found');
     }
     if ($user == $this->user) {
         return $this->respondInsufficientPrivileges('Cant send to yourself');
     }
     $emergency = new Emergency(['sender' => $this->user->id, 'receiver' => $user->id, 'number' => $car->number, 'created_at' => Carbon::now(), 'status' => 'отправлено']);
     $emergency->sender_phone = $this->user->phone->number;
     //FIXME later add custom error to apicontroller
     if ($this->user->urgent_calls == 0) {
         return Response::json(['error' => ['message' => 'Вы исчерпали лимит срочных вызовов                   (' . $limit . ' в день)', 'status_code' => 1003]], 403);
     }
     $this->user->urgent_calls--;
     $this->user->emergencies()->save($emergency);
     $this->user->save();
     Queue::later(30, 'smsSender', $emergency);
     Queue::later(60, 'smsChecker', $emergency->id);
     $response['emergencies'] = ['id' => $emergency->id, 'sender' => $emergency->sender, 'created_at' => $emergency->created_at, 'number' => $emergency->number, 'phone_number' => $emergency->sender_phone, 'delivered_at' => $emergency->delivered_at, 'status' => $emergency->status, 'via_sms' => false, 'complained_at' => $emergency->complained_at, 'failed' => $emergency->failed];
     $response['tries'] = $this->user->urgent_calls;
     $urgentCalls = $this->user->urgent_calls;
     $emergency->phone_number = (int) $this->user->phone->number;
     $emergency->receiverU->devices->each(function ($device) use($emergency, $urgentCalls) {
         $stateSender = new StateSender($device->auth_token);
         $stateSender->setEmergencyAdded($emergency, $urgentCalls);
         $stateSender->send();
     });
     // Probably wiser to send state to self as well, and show only by response from state
     //		$emergency->getMembersTokens()->each(function ($token) use($emergency, $urgentCalls) {
     //			$stateSender = new StateSender($token->auth_token);
     //			$stateSender->setEmergencyAdded($emergency, $this->user->urgent_calls);
     //			$stateSender->send();
     //		});
     return $this->respond($response);
 }
开发者ID:SenhorBardell,项目名称:yol,代码行数:46,代码来源:EmergenciesController.php

示例2: store

 /**
  * Create new chat
  * @return CarChat|\Illuminate\Http\JsonResponse
  */
 public function store()
 {
     $number = Input::get('number');
     $car = Car::where('number', Input::get('number'))->first();
     if (!$car) {
         return $this->respondNotFound('user.car-not-found');
     }
     if (!$car->user) {
         return $this->respondNotFound('user.not-found');
     }
     if ($car->user->id == $this->user->id) {
         return $this->respondInsufficientPrivileges('user.self-car-talk');
     }
     if ($car->user->delete_at) {
         return $this->respondNotFound('user.not-associated-with-car');
     }
     if ($this->user->isBlocked($car->user->id)) {
         return $this->respondInsufficientPrivileges('user.blocked');
     }
     if ($this->user->sex == $car->user->sex) {
         return $this->respondInsufficientPrivileges('chat.same-sex');
     }
     if (!$car->user->enable_carchats) {
         return $this->respondInsufficientPrivileges('chat.carchats-not-accepting');
     }
     $chat = CarChat::byNumber($car->number)->where('owner_id', $this->user->id)->first();
     //TODO if was deleted by all side remove deleted flag
     if ($chat) {
         $chat->load(['owner', 'receiver', 'receiverCar']);
         if ($chat->isOwner($this->user->id)) {
             $chat->deleted_by_owner = false;
         } else {
             $chat->deleted_by_receiver = false;
         }
         if ($chat->save()) {
             return $this->respond($this->collectionTransformer->transformChat($chat, $this->user->id));
         }
     }
     $chat = new CarChat(['number' => $car->number, 'receiver_id' => $car->user_id, 'receiver_car_id' => $car->id]);
     $chat->updated_at = Carbon::now();
     if ($this->user->myCarChats()->save($chat)) {
         return $this->respond($this->collectionTransformer->transformChat($chat, $this->user->id));
     }
     return $this->respondServerError();
 }
开发者ID:SenhorBardell,项目名称:yol,代码行数:49,代码来源:CarChatsController.php

示例3: del_car

 /**
  * function name : delete
  * edit data c_cars
  * get
  */
 public function del_car($id)
 {
     if (Session::get('level') == '1') {
         $result = Car::where('car_id', $id)->delete();
         if ($result) {
             return Redirect::to('cars')->with('success_message', 'ลบข้อมูลเรียบร้อยแล้ว');
         } else {
             return Redirect::to('cars')->with('error_message', 'ไม่สามารถลบข้อมูลได้ กรุณาแจ้งผู้ดูแลระบบ');
         }
     } else {
         $data = DB::Select('select car_id, car_number, brand, model, car_img from c_cars');
         return View::make('home.index', array('data' => $data));
     }
 }
开发者ID:themesanasang,项目名称:car,代码行数:19,代码来源:AdminController.php

示例4: getSearch

 public function getSearch()
 {
     $keyword = Input::get('keyword');
     return View::make('store.search')->with('cars', Car::where('title', 'LIKE', '%' . $keyword . '%')->get())->with('keyword', $keyword);
 }
开发者ID:madiarsa,项目名称:laravel-4.1-car-rental-site,代码行数:5,代码来源:StoreController.php

示例5: testNoResultsfindPairs

 public function testNoResultsfindPairs()
 {
     $pairs = Car::where('id', 10)->find_pairs('id', 'name');
     $this->assertNull($pairs);
 }
开发者ID:surt,项目名称:granada,代码行数:5,代码来源:GranadaNewTest.php


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