<commit_before><?php

namespace Suyabay\Http\Controllers;

use Illuminate\Http\Request;
use Suyabay\Http\Requests;
use Suyabay\Http\Controllers\Controller;

class SearchController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return redirect('/');

    }

}
<commit_msg>[Feature: #112579483] Add search controller to make searches possible<commit_after><?php

namespace Suyabay\Http\Controllers;

use Illuminate\Http\Request;
use Suyabay\Episode;
use Suyabay\Channel;

class SearchController extends Controller
{
    /**
     * Perform a search query and return results
     * if any otherwise notify user No results.
     */
    public function getResults(Request $request)
    {
        $query = $request->input('query');

        if (!$query) {
            return redirect()
            ->route('home')
            ->with('info', 'Could not find what you searched for');
        }

        if (env('APP_ENV') === 'testing') {
            $results = Episode::where('episode_name', 'LIKE', "%{$query}%")
                            ->orWhere('episode_description', 'LIKE', "%{$query}%")
                            ->get();
        } else {
            $results = Episode::where('episode_name', 'ILIKE', "%{$query}%")
                            ->orWhere('episode_description', 'ILIKE', "%{$query}%")
                            ->get();
        }

        $channels = Channel::all();

        return view('app.pages.search')->with([
            'results' => $results,
            'channels' => $channels,
        ]);
    }
}

{'fraction_non_alphanumeric': 0.145366444579043, 'fraction_numerical': 0.005451241671714113, 'mean_word_length': 2.116981132075472, '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': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5513708', 'n_tokens_mistral': 477, 'n_tokens_neox': 470, 'n_words': 108}