Esempio n. 1
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->bind('facility', function ($slug) {
         return \App\Facility::where('slug', $slug)->first();
     });
     $router->bind('type', function ($slug) {
         return \App\RoomType::where('slug', $slug)->first();
     });
     $router->bind('room', function ($room_no) {
         return \App\Room::where('room_no', $room_no)->first();
     });
     $router->model('reservation', 'App\\Reservation');
     parent::boot($router);
 }
Esempio n. 2
0
 public function searchAvailability(Request $request)
 {
     $start_dt = Carbon::createFromFormat('d-m-Y', $request['start_dt'])->toDateTimeString();
     $end_dt = Carbon::createFromFormat('d-m-Y', $request['end_dt'])->toDateTimeString();
     $min_occupancy = $request['min_occupancy'];
     $room_types = RoomType::where('max_occupancy', '>=', $min_occupancy)->get();
     $available_room_types = [];
     foreach ($room_types as $room_type) {
         $count = RoomCalendar::where('day', '>=', $start_dt)->where('day', '<', $end_dt)->where('room_type_id', '=', $room_type->id)->where('availability', '<=', 0)->count();
         if ($count == 0) {
             $total_price = RoomCalendar::where('day', '>=', $start_dt)->where('day', '<', $end_dt)->where('room_type_id', '=', $room_type->id)->sum('rate');
             $room_type->total_price = $total_price;
             array_push($available_room_types, $room_type);
         }
     }
     return $available_room_types;
 }
 public function deleteRoomType($id)
 {
     RoomType::where('id', $id)->delete();
     return redirect()->route('listroomtype_com');
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create($property_id)
 {
     //
     $room_types = RoomType::where('property_id', '=', $property_id)->lists('name', 'id');
     return view('room.create')->with('property_id', $property_id)->with('room_types', $room_types);
 }