Exemplo n.º 1
0
 public function setPriceInRangeForRoomType(Request $request)
 {
     $room_type = $request['room_type'];
     $price = $request['price'];
     $start_dt = $request['start_dt'];
     $end_dt = $request['end_dt'];
     $date = date("Y-m-d", strtotime($start_dt));
     $base_room = RoomType::find($room_type);
     $i = 0;
     while (strtotime($date) <= strtotime($end_dt)) {
         $room_day = RoomCalendar::firstOrNew(array('room_type_id' => $room_type, 'day' => $date));
         if (!$room_day->id) {
             $room_day->availability = $base_room->base_availability;
         }
         $room_day->rate = $price;
         $room_day->save();
         $date = date("Y-m-d", strtotime("+1 day", strtotime($date)));
         $i++;
     }
     return response("Success updated " . $i . " dates", 200);
 }
Exemplo n.º 2
0
 /**
  * edit room tye info
  *
  * @param Request $request
  * @return \Illuminate\Http\JsonResponse
  *
  */
 public function admin_edit_roomtype(Request $request)
 {
     $roomType = RoomType::find($request->input('id'));
     $id = $request->input('id');
     $rate = DB::select(DB::raw("select a.*,\n        (select b.meal_type_name from MEAL_TYPES b  where b.meal_type_id = a.meal_type_id) as meal\n        from RATES a where a.room_type_id = '{$id}'"));
     //RATE::where('room_type_id',$request->input('id'))->get();
     $images = ROOM_IMAGE::where('room_type_id', $request->input('id'))->get();
     $rf = RoomTypeFurnish::where('room_type_id', $request->input('id'))->get();
     $rs = RoomTypeService::where('room_type_id', $request->input('id'))->get();
     return response()->json(['info' => $roomType, 'images' => $images, 'rs' => $rs, 'rf' => $rf, 'rate' => $rate]);
 }
Exemplo n.º 3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $roomType = RoomType::find($id);
     $roomType->delete();
 }
Exemplo n.º 4
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($roomTypeId)
 {
     return response()->json(RoomType::find($roomTypeId)->rooms);
 }