public function questions() { if (Auth::check()) { $comments = Comment::whereHas('ad', function ($query) { $query->where(['author_id' => Auth::user()->id, 'answer_to' => null]); })->orWhereHas('answerTo', function ($query) { $query->where('author_id', Auth::user()->id); })->orderBy('created_at', 'desc')->get(); return view('profile.questions', ['categories' => Category::getAll(), 'comments' => $comments]); } else { return redirect('/'); } }