コード例 #1
0
 public function getBookCar()
 {
     $car = Car::find(Input::get('id'));
     if ($car) {
         return View::make('store.booking')->with('car', Car::find(Input::get('id')));
     }
     return Redirect::to('/')->with('message', 'invalid car id, please try again');
 }
コード例 #2
0
function updateCar($id)
{
    $request = Slim\Slim::getInstance()->request();
    $car = Car::find($id);
    $car_getbody = json_decode($request->getBody());
    $car->modelC = $car_getbody->modelC;
    $car->brandC = $car_getbody->brandC;
    $car->registrationC = $car_getbody->registrationC;
    $car->save();
    echo $car;
}
コード例 #3
0
 public function postUpdate()
 {
     $car = Car::find(Input::get('id'));
     if ($car) {
         $car->type_id = Input::get('type_id');
         $car->title = Input::get('title');
         $car->description = Input::get('description');
         $car->price = Input::get('price');
         $car->available_at = Input::get('available_at');
         $car->transmission = Input::get('transmission');
         $car->aircon = Input::get('aircon');
         $car->seats = Input::get('seats');
         $car->doors = Input::get('doors');
         $car->save();
         return Redirect::to('admin/cars/index')->with('message', 'Car Details Updated');
     }
     return Redirect::to('admin/cars/index')->with('message', 'Invalid Car ID');
 }
コード例 #4
0
 public function applyForServiceAction()
 {
     $user = $this->getAuth();
     $cars = Car::find(array('conditions' => 'owner = ?1', 'bind' => array(1 => $user['user_id'])));
     $full_dates = "";
     $date = new DateTime("now");
     $day = new DateInterval("P1D");
     for ($i = 0; $i < 21; $i++) {
         $apps = Application::find(array('conditions' => 'term >= ?1 AND term <= ?2', 'bind' => array(1 => $date->format('Y.m.d') . ' 00:00', 2 => $date->format('Y.m.d') . ' 24:00')));
         if (count($apps) >= 4 * 20) {
             $full_dates .= "'" . $date->format('m.d.Y') . "', ";
         }
         $date->add($day);
     }
     $services = Service::find();
     $this->view->setParamToView('cars', $cars);
     $this->view->setParamToView('dates', $full_dates);
     $this->view->setParamToView('services', $services);
 }
コード例 #5
0
 /**
  * testFindRecord.
  *
  * Assert that $car is an instance of the PotatoModel
  *
  * Assert that the returned affected rows is equal to one
  *
  * Assert that the last updated name field is Beetle
  *
  * Aseert that the last updated model is Mulsanne Range
  *
  * Assert that the last updated year is 2015
  */
 public function testFindAndUpdateRecord()
 {
     $car = Car::find(5);
     $car->name = 'Beetle';
     $affectedRows = $car->save();
     $cars = Car::getAll();
     $this->assertTrue($car instanceof PotatoModel);
     $this->assertEquals(1, $affectedRows);
     $this->assertEquals('Beetle', $cars[4]['name']);
     $this->assertEquals('Mulsanne Range', $cars[4]['model']);
     $this->assertEquals(2015, $cars[4]['year']);
 }
コード例 #6
0
ファイル: Collection.php プロジェクト: peacq/picorm
 /**
  * @engine isolate
  * @dataProvider createAndSaveRawModelWithOneToManyRelation
  */
 public function testHas($testBrand, $cars)
 {
     $collection = \Car::find();
     $this->boolean($collection->has(1))->isEqualTo(true);
     $this->boolean($collection->has(10))->isEqualTo(false);
 }
コード例 #7
0
ファイル: CarsController.php プロジェクト: kenkode/umash-1
 /**
  * Show the form for editing the specified car.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $car = Car::find($id);
     return View::make('cars.edit', compact('car'));
 }
コード例 #8
0
ファイル: ModelTest.php プロジェクト: amitshukla30/recess
 function testBooleanType()
 {
     $car = new Car();
     $car->isDriveable = true;
     $car->insert();
     $carId = $car->pk;
     $car = new Car();
     $car->pk = $carId;
     $driveable = $car->find()->first()->isDriveable;
     $this->assertEquals($driveable === true, true);
 }
コード例 #9
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $catalog = Catalog::with('car')->find($id);
     $car = Car::find($catalog->car->id);
     $catalog->delete();
     $car->delete();
     return Redirect::route('admin.catalog.index')->with('success', Lang::get('messages.catalog_delete'));
 }
コード例 #10
0
 public function indexAction()
 {
     $this->view->cars = Car::find(["order" => "RAND()"]);
 }
コード例 #11
0
 public function getEdit($id)
 {
     $item = Item::find($id);
     $document = Item::find($id)->document();
     $type = $item->document->os_type;
     switch ($type) {
         case 'movables' || 'value_movables':
             $variable = Item::find($id)->variable();
             return View::make('items.edit', array('item' => $item, 'document' => $document, 'variable' => $variable));
             break;
         case 'car':
             $variable = Item::find($id)->variable();
             $car = Car::find($id)->car();
             return View::make('items.edit', array('item' => $item, 'document' => $document, 'variable' => $variable, 'car' => $car));
             break;
         case 'buildings':
             $variable = Item::find($id)->variable();
             $building = Item::find($id)->building();
             $address = Address::find($id)->address();
             return View::make('items.edit', array('item' => $item, 'document' => $document, 'building' => $building, 'variable' => $variable, 'address' => $address));
             break;
         case 'parcels':
             $parcel = Item::find($id)->parcel();
             $address = Address::find($id)->address();
             return View::make('items.edit', array('item' => $item, 'document' => $document, 'parcel' => $parcel, 'address' => $address));
             break;
     }
 }
コード例 #12
0
ファイル: CarsController.php プロジェクト: Park-It/parkit.dev
 /**
  * Remove the specified car from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $userId = Auth::user()->id;
     $carData = Car::find($id);
     if ($userId === $carData["user_id"]) {
         Log::info("userid: {$userId}, car: {$id} Deleted.");
         $carParking = DB::table('car_parking_lots')->where('car_id', $id);
         $carParking->delete();
         Car::destroy($id);
         return Redirect::route('cars.index');
     } else {
         return "Access Denied: this is not your car.";
     }
 }
コード例 #13
0
ファイル: showcar.php プロジェクト: k-integer/2cars
 function get_cars()
 {
     $this->lastCars = LastCar::first();
     $this->carsSelf = Car::find('all', array('select' => 'id,name,photo,count_visit', 'conditions' => 'id not in(' . $this->lastCars->cars_id . ')', 'limit' => 2, 'order' => 'count_visit asc, rand()'));
 }
コード例 #14
0
 /**
  * Store a newly message.
  *
  * @return Response
  */
 public function send()
 {
     $chatId = Input::get('chat_id');
     $user = Auth::user();
     if (($content = Input::get('content')) && (int) $chatId > 0 && !is_null($chat = Chat::find((int) $chatId)) && $chat->hasMember($user->id)) {
         foreach ($chat->getUsersIds() as $id) {
             if ($user->isBlocked($id)) {
                 return Response::json(['error' => ['message' => 'Cant send to group with users which blocked', 'status_code' => 1002]], 403);
             }
         }
         if (isset($content['text']) || isset($content['image_id']) && MessageAttachment::whereRaw('id = ? and chat_id = ?', array((int) $content['image_id'], $chat->id))->get()->count() > 0 || isset($content['car']) && ($car = Car::find((int) $content['car']['id'])) || isset($content['geo']) && isset($content['geo']['lat']) && isset($content['geo']['long']) && isset($content['geo']['location'])) {
             if (isset($content['text']) && strlen($content['text']) > 2500) {
                 return $this->respondInsufficientPrivileges('Слишком длинный текст');
             }
             $message = new Message();
             $message->chat_id = $chat->id;
             $message->user_id = $user->id;
             if (isset($content['text'])) {
                 $message->text = $content['text'];
                 //                } else if(isset($content['image_id'])) {
                 //                    $message->image_id = (int)$content['image_id'];
             } else {
                 if (isset($content['car'])) {
                     $message->car_id = $car->id;
                     if ((bool) $content['car']['car_with_number']) {
                         $message->car_number = $car->number;
                     }
                 } else {
                     if (isset($content['geo'])) {
                         $message->lat = $content['geo']['lat'];
                         $message->lng = $content['geo']['long'];
                         $message->location = $content['geo']['location'];
                     }
                 }
             }
             if (isset($content['image_id'])) {
                 $message->image_id = (int) $content['image_id'];
             }
             $message->save();
             $chat->timestamp = DB::raw('NOW()');
             $chat->save();
             foreach ($chat->getUsers() as $user) {
                 $unread = new MessageUnread();
                 $unread->message_id = $message->id;
                 $unread->user_id = $user->id;
                 $unread->chat_id = $chat->id;
                 $unread->save();
             }
             $message = Message::find($message->id);
             foreach ($chat->getMembersTokens() as $token) {
                 $state = new StateSender($token);
                 $state->setMessageAsAdded($message->getAsArray(true));
                 $state->send();
             }
             return $this->respond($message->getAsArray());
         } else {
             return $this->setStatusCode(403)->respondWithError('Unset necessary parameter in correct format');
         }
     } else {
         return $this->setStatusCode(500)->respondWithError('Chat doesn\'t exist');
     }
 }