/**
  * Creates a vehicle
  *
  * @param  array  $data - Input data
  * @return int - New vehicle id
  */
 public function create(array $data)
 {
     $vehicle = new Vehicle();
     $vehicle->year = $data['year'];
     $vehicle->model_id = $data['model_id'];
     $vehicle->mileage = $data['mileage'];
     $vehicle->vin = $data['vin'];
     $vehicle->save();
     return $vehicle->id;
 }
 public function run()
 {
     $faker = Faker::create();
     $modelIds = Model::lists('id');
     for ($i = 0; $i < 20; $i++) {
         Vehicle::create(['year' => $faker->year(), 'model_id' => $faker->randomElement($modelIds->toArray()), 'mileage' => $faker->numberBetween(0, 200000), 'vin' => $faker->bothify('##?#???##?##???#??#')]);
     }
 }
 /**
  * Display the specified resource.
  * GET /vehicle/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function show(VehicleTransformer $transformer, $id)
 {
     try {
         $vehicle = Vehicle::findOrFail($id);
     } catch (ModelNotFoundException $e) {
         return $this->respondNotFound('Vehicle does not exist');
     }
     return $this->respondOk(['vehicle' => $transformer->transform($vehicle)]);
 }