/** * Update the specified car in storage. * * @param int $id * @return Response */ public function update($id) { $car = Car::findOrFail($id); $validator = Validator::make($data = Input::all(), Car::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $car->reg_no = Input::get('reg_no'); $car->make = Input::get('make'); $car->driver = Input::get('driver'); $car->status = 'available'; $car->driver_contact = Input::get('driver_contact'); $car->update(); return Redirect::route('cars.index'); }
/** * Update the specified booking in storage. * * @param int $id * @return Response */ public function update($id) { $booking = Booking::findOrFail($id); $validator = Validator::make($data = Input::all(), Booking::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $client = Client::findOrFail(Input::get('client_id')); $car = Car::findOrFail(Input::get('car_id')); $booking->client()->associate($client); $booking->car()->associate($car); $booking->destination = Input::get('destination'); $booking->date_out = Input::get('date_out'); $booking->date_back = Input::get('date_back'); $booking->update(); return Redirect::route('bookings.index'); }
/** * Update the specified car in storage. * * @param int $id * @return Response */ public function update($id) { $userId = Auth::user()->id; $carData = Car::find($id); if ($userId === $carData["user_id"]) { $car = Car::findOrFail($id); $messages = array('new_make.required' => 'Make field cannot be left empty.', 'new_make.max' => 'You must enter a value with a maximum of 255 characters.', 'new_model.required' => 'Model field cannot be left empty.', 'new_model.max' => 'You must enter a value with a maximum of 255 characters.', 'new_license_plate_number.required' => 'License Plate Number field cannot be left empty.', 'new_license_plate_number.max' => 'You must enter a value with a maximum of 255 characters.', 'new_color.required' => 'Color field cannot be left empty.', 'new_color.max' => 'You must enter a value with a maximum of 255 characters.'); $validator = Validator::make($data = Input::all(), Car::$new_rules, $messages); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } else { $car->make = Input::get('new_make'); $car->model = Input::get('new_model'); $car->license_plate_number = Input::get('new_license_plate_number'); $car->color = Input::get('new_color'); $result = $car->save(); } if ($result) { Session::flash('successMessage', 'Your vehicle was successfully updated'); return Redirect::route('cars.index'); } else { Session::flash('errorMessage', 'Please properly input all the required fields'); Log::warning('Vehicle failed to save: ', Input::all()); return Redirect::back()->withInput(); } } else { return "Access Denied: this is not your car."; } }