public function timeLine() { $tags = Auth::user()->tags()->get(); $posts = collect([]); foreach ($tags as $tag) { foreach ($tag->post()->get() as $post) { if (!Auth::user()->type) { if (!$post->private) { $posts->push($post); } else { if ($post->user_id == Auth::id()) { $posts->push($post); } } } else { $posts->push($post); } } } $posts = new Paginator($posts->unique('id'), 10); if (strpos(redirect()->back()->getTargetUrl(), 'login') === false) { return view('welcome', compact('posts', 'tags')); } else { return view('welcome', compact('posts', 'tags'))->with('message', 'Welcome ' . Auth::user()->fullName()); } }