本文整理汇总了PHP中Club::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Club::orderBy方法的具体用法?PHP Club::orderBy怎么用?PHP Club::orderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Club
的用法示例。
在下文中一共展示了Club::orderBy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showWeek
/**
* Generate the view of the week for given month and given year
* with events in this period.
*
* @param string $year
* @param string $week
* @return view weekView
*
*
*/
public function showWeek($year, $week)
{
// Create week start date on monday (day 1)
$weekStart = date('Y-m-d', strtotime($year . "W" . $week . '1'));
// Create the number of the next week
$nextWeek = date("W", strtotime("next Week" . $weekStart));
$nextYear = date("Y", strtotime("next Week" . $weekStart));
// Create week end date - we go till tuesday (day 2) because café needs alternative week view (Mi-Di)
$weekEnd = date('Y-m-d', strtotime($nextYear . "W" . $nextWeek . '2'));
// Create the number of the previous week
$previousWeek = date("W", strtotime("previous Week" . $weekStart));
$previousYear = date("Y", strtotime("previous Week" . $weekStart));
// Convert number of prev/next week to verbatim format - needed for correct << and >> button links
$nextWeek = $nextYear . "/KW" . $nextWeek;
$previousWeek = $previousYear . "/KW" . $previousWeek;
$date = array('year' => $year, 'week' => $week, 'weekStart' => $weekStart, 'weekEnd' => $weekEnd, 'nextWeek' => $nextWeek, 'previousWeek' => $previousWeek);
$events = ClubEvent::where('evnt_date_start', '>=', $weekStart)->where('evnt_date_start', '<=', $weekEnd)->with('getPlace', 'getSchedule.getEntries.getJobType', 'getSchedule.getEntries.getPerson.getClub')->orderBy('evnt_date_start')->orderBy('evnt_time_start')->get();
$tasks = Schedule::where('schdl_show_in_week_view', '=', '1')->where('schdl_due_date', '>=', $weekStart)->where('schdl_due_date', '<=', $weekEnd)->with('getEntries.getPerson.getClub', 'getEntries.getJobType')->get();
// TODO: don't use raw query, rewrite with eloquent.
$persons = Cache::remember('personsForDropDown', 10, function () {
$timeSpan = new DateTime("now");
$timeSpan = $timeSpan->sub(DateInterval::createFromDateString('3 months'));
return Person::whereRaw("prsn_ldap_id IS NOT NULL \n\t\t\t\t\t\t\t\t\t\t AND (prsn_status IN ('aktiv', 'kandidat') \n\t\t\t\t\t\t\t\t\t\t OR updated_at>='" . $timeSpan->format('Y-m-d H:i:s') . "')")->orderBy('clb_id')->orderBy('prsn_name')->get();
});
$clubs = Club::orderBy('clb_title')->lists('clb_title', 'id');
// IDs of schedules shown, needed for bulk-update
$updateIds = array();
foreach ($events as $event) {
array_push($updateIds, $event->getSchedule->id);
}
return View::make('weekView', compact('events', 'schedules', 'date', 'tasks', 'entries', 'weekStart', 'weekEnd', 'persons', 'clubs'));
}
示例2: showId
/**
* Generates the view for a specific event, including the schedule.
*
* @param int $id
* @return view ClubEventView
* @return ClubEvent $clubEvent
* @return ScheduleEntry[] $entries
* @return RedirectResponse
*/
public function showId($id)
{
$clubEvent = ClubEvent::with('getPlace')->findOrFail($id);
if (!Session::has('userId') and $clubEvent->evnt_is_private == 1) {
Session::put('message', Config::get('messages_de.access-denied'));
Session::put('msgType', 'danger');
return Redirect::action('MonthController@showMonth', array('year' => date('Y'), 'month' => date('m')));
}
$schedule = Schedule::findOrFail($clubEvent->getSchedule->id);
$entries = ScheduleEntry::where('schdl_id', '=', $schedule->id)->with('getJobType', 'getPerson', 'getPerson.getClub')->get();
$clubs = Club::orderBy('clb_title')->lists('clb_title', 'id');
$persons = Cache::remember('personsForDropDown', 10, function () {
$timeSpan = new DateTime("now");
$timeSpan = $timeSpan->sub(DateInterval::createFromDateString('3 months'));
return Person::whereRaw("prsn_ldap_id IS NOT NULL AND (prsn_status IN ('aktiv', 'kandidat') OR updated_at>='" . $timeSpan->format('Y-m-d H:i:s') . "')")->orderBy('clb_id')->orderBy('prsn_name')->get();
});
$revisions = json_decode($clubEvent->getSchedule->entry_revisions, true);
if (!is_null($revisions)) {
// deleting ip adresses from output for privacy reasons
foreach ($revisions as $entry) {
unset($entry["from ip"]);
}
}
return View::make('clubEventView', compact('clubEvent', 'entries', 'clubs', 'persons', 'revisions'));
}