public function index() { if (Auth::check()) { if (Auth::user()->role->name === 'admin') { $threads = Thread::paginate(20); } else { $threads = Thread::departmentThreads(Auth::user()->department->id)->paginate(20); } } else { $threads = Thread::publicThreads()->paginate(20); } return view('threads.index', compact('threads')); }