예제 #1
0
 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'));
 }
 public function activities()
 {
     $this->data['activities'] = Activity::orderBy('id', 'desc')->paginate(25);
     return $this->layout->content = View::make('activities', $this->data);
 }
예제 #3
0
파일: LOFaker.php 프로젝트: vanderlin/halp
 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);
 }