<commit_before><?php namespace App\Http\Controllers;

use Topic;
use Discussion;
use Illuminate\Http\Request;

class TopicsController extends Controller
{
	public function __construct()
	{
		parent::__construct();
	}
		if ($topic->exists) {
			$discussions = $topic->discussions()->latest()->get();
		} else {
			$discussions = Discussion::latest()->get();
		}

		return view('pages.discussions.index', compact('discussions'));
	}<commit_msg>Add filters to topics controller<commit_after><?php namespace App\Http\Controllers;

use Topic;
use Discussion;
use Illuminate\Http\Request;
use App\Filters\DiscussionFilters;

class TopicsController extends Controller
{
	public function __construct()
	{
		parent::__construct();
	}
	
	public function discussions(Topic $topic, DiscussionFilters $filters)
	{
		$discussions = Discussion::latest()->filter($filters);

		if ($topic->exists) {
			$discussions->where('topic_id', $topic->id);
		}

		$discussions = $discussions->get();

		return view('pages.discussions.index', compact('discussions'));
	}
{'fraction_non_alphanumeric': 0.14956855225311602, 'fraction_numerical': 0.0, 'mean_word_length': 5.525, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1355973', 'n_tokens_mistral': 342, 'n_tokens_neox': 311, 'n_words': 67}