本文整理汇总了PHP中Vehicle类的典型用法代码示例。如果您正苦于以下问题:PHP Vehicle类的具体用法?PHP Vehicle怎么用?PHP Vehicle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Vehicle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeAddVehicle
public function executeAddVehicle(sfWebRequest $request)
{
$v = new Vehicle();
$v->setUserId($this->getUserIdFromRouteOrSession());
$this->form = new VehicleForm($v);
$this->processVehicleForm($request, $this->form);
$this->setTemplate('noVehicle');
}
示例2: getForm
public function getForm($object = null, $options = array())
{
if (null === $object) {
$object = new Vehicle();
}
$object->setUserId($this->getUserId());
return parent::getForm($object, $options);
}
示例3: executeCreate
public function executeCreate(sfWebRequest $request)
{
$charge = new Vehicle();
$charge->setUserId($this->getUserIdFromRouteOrSession());
$this->form = $this->configuration->getForm($charge);
$this->vehicle = $charge;
$this->processForm($request, $this->form);
$this->setTemplate('new');
}
示例4: getAllVehicles
public function getAllVehicles()
{
$db = new Db();
$vehicles = array();
$results = $db->select("select vehicleID as vid, orderOwned, type, modelYear,\n make, model, color, numCyl, transType, purchaseYear, modifiedDate from vehicles;");
foreach ($results as $result) {
$vehicle = new Vehicle();
$vehicle->hydrate($result);
$vehicles[] = $vehicle;
}
return $vehicles;
}
示例5: selectByCollection
public static function selectByCollection($id)
{
$connection = Flight::dbMain();
try {
$sql = "SELECT * FROM vehicle_collection WHERE collection_id = :collection_id;";
$query = $connection->prepare($sql);
$query->bindParam(':collection_id', $id, PDO::PARAM_INT);
$query->execute();
$rows = $query->fetchAll(PDO::FETCH_ASSOC);
$result = array();
foreach ($rows as $row) {
$vehicleCollection = new VehicleCollection();
$vehicleCollection->Id = (int) $row['id'];
$vehicleCollection->Vehicle = Vehicle::select($row['vehicle_id']);
$vehicleCollection->Collection = Collection::select($row['collection_id']);
array_push($result, $vehicleCollection);
}
return $result;
} catch (PDOException $pdoException) {
throw $pdoException;
} catch (Exception $exception) {
throw $exception;
} finally {
$connection = null;
}
}
示例6: consumption
public static function consumption($v)
{
$vid = Vehicle::getVehicle($v);
$users = User::getUserIDs($vid["idvehicle"]);
if ($users != NULL) {
$uid = array();
//usersIDs
foreach ($users as $key => $value) {
array_push($uid, intval($users[$key]["iduser"]));
}
$consumption = array();
//consumption by userID
foreach ($uid as $key => $value) {
$data = Data::getDataBrowse($value);
if ($data != NULL && $data["max"] != NULL && $data["min"] != NULL && $data["fuel"] != NULL) {
$avg = intval($data["fuel"]) / (intval($data["max"]) - intval($data["min"])) * 100;
array_push($consumption, $avg);
}
}
if (!empty($consumption)) {
$avg = round(array_sum($consumption) / count($consumption), 2) . "L/100km";
$min = round(min($consumption), 2) . "L/100km";
$max = round(max($consumption), 2) . "L/100km";
return [$avg, $min, $max];
}
}
}
示例7: run
public function run()
{
Vehicle::create(array('id' => 1, 'plate' => 'GNM504', 'color' => 'Rojo', 'brand' => 'Renault', 'model' => 'Twingo 2007', 'capacity' => 4, 'status' => 1, 'type' => 1, 'users_id' => 1));
Vehicle::create(array('id' => 2, 'plate' => 'FKJ324', 'color' => 'Azul', 'brand' => 'Renault', 'model' => 'Clio 2008', 'capacity' => 2, 'status' => 1, 'type' => 1, 'users_id' => 2));
Vehicle::create(array('id' => 3, 'plate' => 'HJJ832', 'color' => 'Verde', 'brand' => 'Renault', 'model' => 'Sandero 2010', 'capacity' => 2, 'status' => 1, 'type' => 1, 'users_id' => 3));
Vehicle::create(array('id' => 4, 'plate' => 'FMJ313', 'color' => 'Negro', 'brand' => 'Ford', 'model' => 'Fordsito 2014', 'capacity' => 3, 'status' => 1, 'type' => 1, 'users_id' => 4));
}
示例8: destroy
public function destroy()
{
$datos = Input::all();
$vehicle = Vehicle::find($datos['id']);
$vehicle->status = 0;
$vehicle->save();
return Redirect::intended('/vehiclelist');
}
示例9: actionIndex
public function actionIndex()
{
$criteria = new CDbCriteria();
$pages = new CPagination(Vehicle::model()->count($criteria));
$pages->pageSize = 8;
$pages->applyLimit($criteria);
$vehicles = Vehicle::model()->findAll($criteria);
$this->render('home', array('vehicles' => $vehicles, 'pages' => $pages));
}
示例10: getCylindersCounts
public function getCylindersCounts()
{
$entities = array();
$cylinders = Vehicle::distinct()->select('cylinders')->orderBy('cylinders')->where('cylinders', '>', 0)->get();
foreach ($cylinders as $cylinder) {
array_push($entities, (object) ['id' => $cylinder->cylinders, 'cylinders' => $cylinder->cylinders . ' Cylinders']);
}
return $this->getPropertiesList($entities, 'cylinders');
}
示例11: create
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
$vehicles = Vehicle::where('users_id', '=', Auth::user()->id)->get();
if ($vehicles->count() > 0) {
return View::make('chances.create', compact('vehicles'));
} else {
return View::make('vehicles.create')->withErrors('You must add a vehicle to create a Chance');
}
}
示例12: destroy
public function destroy($id)
{
$vehicle = Vehicle::find($id);
$result = $vehicle->delete();
if ($result) {
return $this->index();
} else {
return $this->index();
}
}
示例13: getProcessedVehiclesSum
public static function getProcessedVehiclesSum($start, $end)
{
$processedList = DB::select(DB::raw("SELECT e_v.vehicle_fk, COUNT(*) as quantity\n FROM employees_vehicles AS e_v, invoices AS inv\n WHERE inv.date >= '{$start}'\n AND inv.date <= '{$end}'\n AND inv.id = e_v.invoice_fk\n AND inv.deleted_at IS NULL\n AND e_v.deleted_at IS NULL\n GROUP BY e_v.vehicle_fk"));
$totalSum = 0;
foreach ($processedList as $process) {
$price = Vehicle::getEmployeesCut($process->vehicle_fk);
$total = $price * $process->quantity;
$totalSum += $total;
}
return $totalSum;
}
示例14: testCreate
public function testCreate()
{
$vehicle = new Vehicle();
$vehicle->setMPG(25);
$vehicle->setUser(new User());
$vehicle->setMake(new Make());
$this->assertSame(25, $vehicle->getMPG());
$this->assertTrue($vehicle->getUser() instanceof User);
$this->assertTrue($vehicle->getMake() instanceof Make);
}
示例15: download
public function download($id)
{
$invoiceInfo = Invoice::find($id);
$invoiceElements = InvoiceElement::getInvoiceElements($id);
$employeeInfo = Employee::withTrashed()->find($invoiceElements[0]->employee_fk);
$elementData = [];
foreach ($invoiceElements as $element) {
$price = Vehicle::withTrashed()->where('id', '=', $element->vehicle_fk)->pluck('price');
$type = Vehicle::withTrashed()->where('id', '=', $element->vehicle_fk)->pluck('type');
$elementData[$element->vehicle_fk] = ['type' => $type, 'price' => $price];
}
$pdf = PDF::loadView('invoice.invoice', ['invoiceInfo' => $invoiceInfo, 'invoiceElements' => $invoiceElements, 'elementData' => $elementData, 'employeeInfo' => $employeeInfo]);
return $pdf->download($invoiceInfo->date . ' - ' . $invoiceInfo->bill_to . '.pdf');
}