Exemple #1
0
 public function showTeam($id, $teamId)
 {
     $action = 'teamwork';
     $user = User::findOrFail($id);
     $team = Team::where('id', $teamId)->first();
     $currentMission = TeamMission::where(['team_id' => $teamId, 'to_user' => \Auth::user()->id])->where('status', '>=', 0)->where('status', '<', 1)->get();
     $allocateMission = TeamMission::where('team_id', $teamId)->where('status', '<>', 4)->get();
     $historyMission = TeamMission::where('team_id', $teamId)->where('status', 4)->get();
     $traces = TeamTrace::latest()->where('team_id', $teamId)->get();
     $first = TeamTrace::latest()->where('team_id', $teamId)->first();
     $first['time'] = substr($first->created_at, 11, 5);
     $timeLines = array();
     $timeLine['date'] = substr($first->created_at, 0, 10);
     $timeLine['day'] = $this->formatDay($first->created_at);
     $tracesArray = array();
     array_push($tracesArray, $first);
     $timeLine['traces'] = $tracesArray;
     array_push($timeLines, $timeLine);
     foreach ($traces as $index => $trace) {
         if ($index > 0) {
             $flag = false;
             $trace['time'] = substr($trace->created_at, 11, 5);
             foreach ($timeLines as $index => &$timeLine) {
                 if ($timeLine['date'] == substr($trace->created_at, 0, 10)) {
                     array_push($timeLine['traces'], $trace);
                     $flag = true;
                 }
             }
             unset($timeLine);
             if (!$flag) {
                 $timeLine['date'] = substr($trace->created_at, 0, 10);
                 $timeLine['day'] = $this->formatDay($trace->created_at);
                 $tracesArray = array();
                 array_push($tracesArray, $trace);
                 $timeLine['traces'] = $tracesArray;
                 array_push($timeLines, $timeLine);
             }
         }
     }
     return view('member.users.team-show', compact('user', 'team', 'action', 'currentMission', 'allocateMission', 'historyMission', 'timeLines'));
 }
Exemple #2
0
 private function createTeamTrace($teamId, $act, $target)
 {
     return TeamTrace::create(array('team_id' => $teamId, 'user_id' => \Auth::user()->id, 'act' => $act, 'target' => $target, 'type' => 1));
 }