diff --git a/src/app/Http/Controllers/TopicsController.php b/src/app/Http/Controllers/TopicsController.php index 121d37a6..ed00e1f5 100644 --- a/src/app/Http/Controllers/TopicsController.php +++ b/src/app/Http/Controllers/TopicsController.php @@ -12,11 +12,12 @@ use LaravelFrance\Http\Requests\SolveTopicRequest; use LaravelFrance\Http\Requests\StoreTopicRequest; use Redirect; +use function foo\func; class TopicsController extends Controller { - public function index($categorySlug = null) + public function index(Request $request, $categorySlug = null) { $chosenCategory = null; if ($categorySlug) { @@ -27,6 +28,22 @@ public function index($categorySlug = null) if (!!$chosenCategory) { $topicsQuery = $topicsQuery->whereForumsCategoryId($chosenCategory->id); } + + if ($request->get('author')) { + $topicsQuery = $topicsQuery->where('forums_topics.user_id', $request->get('author')); + } + + if ($request->get('no-answers')) { + $topicsQuery = $topicsQuery->where('nb_messages', 1); + } + + if ($from = $request->get('with-msg-from')) { + $topicsQuery = $topicsQuery->whereHas('forumsMessages', function ($q) use($from) { + $q->where('forums_messages.user_id', $from); + }); + } + + $topics = $topicsQuery->simplePaginate(Config::get('laravelfrance.forums.topics_per_page')); return view('topics.index', compact('topics', 'chosenCategory')); diff --git a/src/resources/views/layouts/forums_sidebar.blade.php b/src/resources/views/layouts/forums_sidebar.blade.php index 1f8607ee..57dbc510 100644 --- a/src/resources/views/layouts/forums_sidebar.blade.php +++ b/src/resources/views/layouts/forums_sidebar.blade.php @@ -10,3 +10,18 @@