本文整理汇总了PHP中Car::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Car::find方法的具体用法?PHP Car::find怎么用?PHP Car::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Car
的用法示例。
在下文中一共展示了Car::find方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBookCar
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: updateCar
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: postUpdate
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: applyForServiceAction
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: testFindAndUpdateRecord
/**
* 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: testHas
/**
* @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: edit
/**
* 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: testBooleanType
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: destroy
/**
* 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: indexAction
public function indexAction()
{
$this->view->cars = Car::find(["order" => "RAND()"]);
}
示例11: getEdit
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: destroy
/**
* 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: get_cars
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: send
/**
* 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');
}
}