本文整理汇总了PHP中Room::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Room::with方法的具体用法?PHP Room::with怎么用?PHP Room::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Room
的用法示例。
在下文中一共展示了Room::with方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
public function destroy($id)
{
$room = Room::with('schedules')->find($id);
if ($room->schedules->count() > 0) {
Session::flash('message', 'Tidak dapat menghapus ruangan! Ruangan ini digunakan dalam jadwal belajar');
} else {
Room::destroy($id);
Session::flash('message', 'Sukses menghapus ruangan!');
}
}
示例2: getRooms
public function getRooms()
{
$email = Input::get('email');
$pass = Input::get('password');
if (Auth::attempt(array('email' => $email, 'password' => $pass))) {
$user = User::where('email', '=', $email)->first();
$building = $user->buildings->first();
if (!empty($building)) {
$rooms = Room::with('Layouts')->where('building_id', '=', $building->id)->get();
return Response::json($rooms, 200);
} else {
return Response::json(array('message' => 'Something went wrong'), 500);
}
} else {
return Response::json(array('message' => 'Wrong email or password'), 404);
}
}
示例3: thisYearList
public function thisYearList()
{
$today = date("Y");
if (isset($_GET['filtertype'])) {
if ($_GET['filtertype'] != 1) {
$today = isset($_GET['year1']) ? $_GET['year1'] : date("Y");
$room = Room::with('roomQty')->with(array('roomQty.roomReserved' => function ($query) use($today) {
$query->whereRaw('YEAR(check_in) = ' . $today);
}))->select('id', 'name')->get();
$output = [];
return $room;
} else {
$year1 = isset($_GET['year1']) ? $_GET['year1'] : date("Y");
$year2 = isset($_GET['year2']) ? $_GET['year2'] : date("Y");
$year1_result = Room::with('roomQty')->with(array('roomQty.roomReserved' => function ($query) use($year1) {
$query->whereRaw('YEAR(check_in) = ' . $year1);
}))->select('id', 'name')->get();
$year2_result = Room::with('roomQty')->with(array('roomQty.roomReserved' => function ($query) use($year2) {
$query->whereRaw('YEAR(check_in) = ' . $year2);
}))->select('id', 'name')->get();
$result = array();
$result['year1'] = $year1_result;
$result['year2'] = $year2_result;
return $result;
}
}
$booking_recent = ReservedRoom::with('room.roomDetails2')->whereRaw('YEAR(check_in) = ' . $today)->get();
$room = Room::with('roomQty')->with(array('roomQty.roomReserved' => function ($query) use($today) {
$query->whereRaw('YEAR(check_in) = ' . $today);
}))->select('id', 'name')->get();
$output = [];
return $room;
if (!empty($booking_recent)) {
$output['booking'] = $booking_recent;
$output['rooms'] = $room;
return $output;
} else {
return '0';
}
}
示例4: function
Route::get('dashboard/success_booking', 'DashboardController@todayBookingSuccess');
Route::get('dashboard/cancelled_booking', 'DashboardController@todayBookingCancelled');
Route::get('dashboard/pending_booking', 'DashboardController@todayBookingPending');
Route::get('dashboard/arrival', 'DashboardController@todayArrival');
Route::get('dashboard/departure', 'DashboardController@todayDeparture');
Route::get('dashboard/occupied', 'DashboardController@todayBookingOccupied');
Route::get('dashboard/preparing', 'DashboardController@todayBookingPreparing');
Route::get('reservation/list/ajax', 'BookingController@thisYearList');
Route::get('activity', 'ActivitiesController@index');
Route::get('room', 'RoomController@index');
Route::get('room/all', 'RoomController@allrooms');
Route::get('room/search/{query}', function ($query) {
$r = RoomQty::where('room_no', $query)->first();
if (!empty($r)) {
$room_id = $r->room_id;
$rooms = Room::with('roomQty', 'roomImages.photo')->where('id', $room_id)->get();
//return 'heyt';
return $rooms;
} else {
return '0';
}
return 'hey';
});
Route::get('user', 'UsersController@index');
Route::post('user/create', 'UsersController@store');
Route::post('user/{id}/delete', 'UsersController@destroy');
Route::post('user/{id}/update', 'UsersController@update');
Route::get('settings', function () {
$cpage = 'settings';
return View::make('adminview.settings.index', compact('cpage'));
});
示例5: ajaxLiveMonitoring
public function ajaxLiveMonitoring()
{
$i = array();
$today = Date('Y-m-d');
$i['checkin'] = Date('Y-m-d');
$i['checkout'] = new DateTime('tomorrow');
$i['checkout'] = $i['checkout']->format('Y-m-d') . ' 11:59:00';
$room = Room::with(array('roomQty.roomReserved' => function ($query) use($i) {
$query->where(function ($query2) use($i) {
$query2->whereBetween('check_in', array($i['checkin'], $i['checkout']))->orWhereBetween('check_out', array($i['checkin'], $i['checkout']))->orWhereRaw('"' . $i["checkin"] . '" between check_in and check_out')->orWhereRaw('"' . $i["checkout"] . '" between check_in and check_out');
})->where(function ($query3) {
$query3->where('status', '!=', 5)->orWhere('status', '!=', 3);
});
}))->get();
foreach ($room as $i => $r) {
foreach ($r->roomQty as $x => $r_qty) {
if (count($r_qty->roomReserved) > 0) {
if ($r_qty->roomReserved[0]->isOverdue()) {
$room[$i]->roomQty[$x]->roomReserved[0]->status = 6;
//means overdue
}
}
}
}
return $room;
}
示例6: availability
public function availability()
{
$i = Input::all();
if (isset($i['checkin']) && isset($i['checkout'])) {
return $i;
//return $i;
$available_rooms = 0;
$room1 = Room::with(array('roomQty.roomReserved' => function ($query) use($i) {
$query->where(function ($query2) use($i) {
$query2->whereBetween('check_in', array($i['checkin'], $i['checkout']))->orWhereBetween('check_out', array($i['checkin'], $i['checkout']))->orWhereRaw('"' . $i["checkin"] . '" between check_in and check_out')->orWhereRaw('"' . $i["checkout"] . '" between check_in and check_out');
})->where(function ($query3) {
$query3->where('status', '!=', 5)->where('status', '!=', 3);
});
}))->get();
return $room1;
}
}