本文整理汇总了PHP中Activity::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Activity::orderBy方法的具体用法?PHP Activity::orderBy怎么用?PHP Activity::orderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Activity
的用法示例。
在下文中一共展示了Activity::orderBy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insc
public function insc()
{
$events = Event::orderBy('name')->get();
$activitiesNotInsc = Activity::orderBy('name')->get();
$activitiesInsc = Activity::orderBy('name')->get();
return view('activitiesevent', compact('events', 'activitiesInsc', 'activitiesNotInsc'));
}
示例2: activities
public function activities()
{
$this->data['activities'] = Activity::orderBy('id', 'desc')->paginate(25);
return $this->layout->content = View::make('activities', $this->data);
}
示例3: createTimeBinsForActivity
public function createTimeBinsForActivity()
{
$g = [];
$activities = Activity::orderBy('created_at', 'desc')->get();
$prevRow = null;
$lastGroup = array();
foreach ($activities as &$row) {
if (count($g) == 0) {
$uid = "{$row->user_id}" . "_" . $row->created_at->getTimestamp();
$g[$uid] = array($row);
} else {
$group_to_add_to = -1;
$group_index = 0;
// we only want to search to group acts together
// if the activity is of the same type of event
// but not a 'new spot'
// and is a close enough time period (3 mins)
// and from the same user
if ($row->event !== 'activity.user.commented' && $row->event !== 'activity.spot.created') {
foreach ($g as $key => &$group) {
foreach ($group as &$act) {
if ($row->user_id == $act->user_id && $row->created_at->diffInMinutes($act->created_at) <= 30 && $row->event == $act->event) {
$group_to_add_to = $key;
break;
}
}
$group_index++;
}
}
if ($group_to_add_to == -1) {
$uid = "{$row->user_id}" . "_" . $row->created_at->getTimestamp();
$g[$uid] = array($row);
} else {
array_push($g[$group_to_add_to], $row);
}
}
}
foreach ($g as $key => &$group) {
foreach ($group as &$act) {
$act->timestamps = false;
$act->event_id = $key;
$act->save();
}
}
return new Collection($g);
}