public function run() { DB::table('room_info')->delete(); \App\RoomInfo::create(array('room_no' => 'sic-201', 'location' => '2nd floor, C block', 'room_type' => 'classroom', 'capacity' => '70', 'facility' => 'AC')); \App\RoomInfo::create(array('room_no' => 'sic-205', 'location' => '2nd floor, C block', 'room_type' => 'classroom', 'capacity' => '40', 'facility' => 'AC')); \App\RoomInfo::create(array('room_no' => 'sic-301', 'location' => '3nd floor, C block', 'room_type' => 'classroom', 'capacity' => '70', 'facility' => 'AC')); }
public static function getRoomsGreaterThanCapacity($cap) { $mincap = RoomInfo::where('capacity', '>=', $cap)->min('capacity'); // dd($mincap); if (!$mincap) { $lsofrooms = ["msg" => "No rooms of this capacity available"]; } else { $lsofrooms = RoomInfo::whereIn('capacity', [$mincap])->lists('room_no'); } return $lsofrooms; }
/** * Return the list of rooms with capacity greater than the argument passed * * @param Request $request * @return array|string */ public function getroomswithcap(Request $request) { // if ( Session::token() !== Input::get( '_token' ) ) { // return Response::json( array( // 'msg' => 'Unauthorized attempt to create setting' // ) ); // } if ($request->ajax()) { // return "AJAX"; $data = $request->get('data1'); $availrooms = RoomInfo::getRoomsGreaterThanCapacity($data); return $availrooms; // return \Response::json(['success'=>true,'data'=>$data]); // return \Response::json(array( // 'success' => true, // 'data' => $data // )); // return Response::json($data); // return Response::json($response); } else { return "HTTP"; } }
/** * View Current Rooms * * @param Request $request * @return $this */ public function viewroom(Request $request) { $lsofrooms = RoomInfo::getallRooms(); return view('viewroom')->with(['lsofrooms' => $lsofrooms]); // return view('viewroom'); }