app/Http/Controllers/ThreadController.php
// public function index(Channel $channel, ThreadFilters $filters, Trending $trending)
public function index(Channel $channel, ThreadFilters $filters, Trending $trending)
public function index ( Channel $channel ThreadFilters $filters Trending $trending )
public function index(Channel $channel, ThreadFilters $filters)
    {
        $threads = $this->getThreads($channel, $filters);
        if (request()->wantsJson()) {
            return $threads;
        }
        return view('threads.index', [
            'threads' => $threads,
            'channel' => $channel
        ]);
    }
public function index ( Channel $ channel , ThreadFilters $ filters ) { $ threads = $ this -> getThreads ( $ channel , $ filters ) ; if ( request ( ) -> wantsJson ( ) ) { return $ threads ; } return view ( 'threads.index' , [ 'threads' => $ threads , 'channel' => $ channel ] ) ; }
public function index(Channel $channel, ThreadFilters $filters, Trending $trending)
public function index ( Channel $channel ThreadFilters $filters Trending $trending )
// $threads = Thread::filter($filters)->get(); /* if($channel->exists) {
            $threads = $channel->threads()->latest();
        } else {
            $threads = Thread::latest();
        } */ /*
         * When we called the filter method on Thread.php,
         * that will ask our thread filter to apply(See scopeFilter) itself to the query
         * in ThreadFilters, when we accept our request, and call the apply method
         * we will find the user or failed, and apply the user-id to the query
         */ /* $threads = $threads->filter($filters)->get();  */ // if ($username = request('by')) { //     $user = \App\User::where('name', $username)->firstOrFail(); //     $threads->where('user_id', $user->id); // } // $threads = $threads->get(); // $trending = array_map('json_decode', Redis::zrevrange('trending_threads', 0, 4)); // 'trending' => $trending->get()