Ejemplo n.º 1
0
 /**
  * Show user profile view.
  *
  * @param  User  $user
  * @param  string $type
  *
  * @return \Illuminate\View\View
  */
 public function showProfile($user, $type = 'all')
 {
     if ($user->removed_at) {
         App::abort(404, 'Użytkownik usunął konto.');
     }
     if ($type == 'contents') {
         $data['contents'] = $user->contents()->orderBy('created_at', 'desc')->paginate(15);
     } elseif ($type == 'comments') {
         $data['comments'] = $user->comments()->orderBy('created_at', 'desc')->paginate(15);
     } elseif ($type == 'comment_replies') {
         $data['replies'] = $user->commentReplies()->orderBy('created_at', 'desc')->paginate(15);
     } elseif ($type == 'entries') {
         $data['entries'] = $user->entries()->orderBy('created_at', 'desc')->paginate(15);
     } elseif ($type == 'entry_replies') {
         $data['replies'] = $user->entryReplies()->orderBy('created_at', 'desc')->paginate(15);
     } elseif ($type == 'moderated') {
         $data['moderated'] = $user->moderatedGroups()->paginate(25);
     } else {
         $data['actions'] = $user->actions()->with('element')->orderBy('created_at', 'desc')->paginate(15);
     }
     $data['type'] = $type;
     $data['user'] = $user;
     return view('user.profile', $data);
 }