public function update($id)
 {
     $room = Room::findOrFail($id);
     $room->location_id = Input::get('location');
     $room->name = Input::get('name');
     $room->capacity = Input::get('capacity');
     $room->save();
     Session::flash('message', 'Sukses mengupdate ruangan!');
 }
 /**
  * Update the specified room in storage.
  *
  * @param  int $id
  * @return Response
  */
 public function postUpdate($id)
 {
     $room = Room::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Room::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $room->update($data);
     return Redirect::action('RoomsController@getIndex');
 }
 public function postUpdateRates()
 {
     $rules = ['from_date' => 'required|date_format:Y-m-d|after:' . date('Y-m-d', strtotime('yesterday')), 'to_date' => 'required|date_format:Y-m-d|after:' . date('Y-m-d', strtotime('yesterday')), 'week_day' => 'required', 'rooms' => 'required', 'rate' => 'required|numeric|min:0', 'single_rate' => 'numeric|min:0'];
     $validator = Validator::make($data = Input::all(), $rules);
     if ($validator->fails()) {
         return Response::json(['success' => false, 'errors' => $validator->getMessageBag()->toArray()], 400);
         //400 - http error code
     }
     //all ok so get rooms and plans mapping
     $weekDays = $data['week_day'];
     $errors = [];
     $property = Property::findOrFail(Property::getLoggedId());
     foreach ($data['rooms'] as $roomId) {
         //get room data
         $room = Room::findOrFail($roomId);
         $depth = 0;
         $this->updateChannelRate($room, $property, $data, $data['rate'], $weekDays, $errors, $depth);
     }
     if (!empty($errors)) {
         return Response::json(['success' => false, 'errors' => $errors], 400);
         //400 - http error code
     }
     return Response::json(['success' => true], 200);
     //200 - http success code
 }
Exemple #4
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     // get the room
     $room = Room::findOrFail($id);
     // show the edit form and pass the room
     return View::make('rooms.edit')->with('room', $room);
 }