<commit_before><?php

namespace Gallib\Macope\App\Http\Controllers;

use App\Http\Controllers\Controller;
use Gallib\Macope\App\Categorization;
use Gallib\Macope\App\Category;
use Gallib\Macope\App\Http\Requests\CategorizationRequest;

class CategorizationController extends Controller
{

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $categorizations = Categorization::with('category.typeCategory')->get();

        return view('macope::categorizations.index', compact(['categorizations']));
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $categories     = Category::with('typeCategory')->get()->pluck('name_with_type_category', 'id');
        $categorization = new Categorization();
        $searchTypes    = array_combine($categorization->getSearchTypes(), $categorization->getSearchTypes());
        $entryTypes     = array_combine($categorization->getEntryTypes(), $categorization->getEntryTypes());

        return view('macope::categorizations.create', compact(['categories', 'searchTypes', 'entryTypes']));
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Gallib\Macope\App\Http\Requests\CategorizationRequest  $request
     * @return \Illuminate\Http\Response
     */
    public function store(CategorizationRequest $request)
    {
        $categorization = Categorization::create($request->all());

        return redirect()
            ->route('categorizations.index')
            ->withSuccess(['success' => 'The categorization has been added']);

    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $categorization = Categorization::findOrFail($id);

        return view('macope::categorizations.show', compact(['categorization']));
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        $categorization = Categorization::findOrFail($id);
        $categories     = Category::with('typeCategory')->get()->pluck('name_with_type_category', 'id');
        $searchTypes    = array_combine($categorization->getSearchTypes(), $categorization->getSearchTypes());
        $entryTypes     = array_combine($categorization->getEntryTypes(), $categorization->getEntryTypes());

        return view('macope::categorizations.edit', compact(['categorization', 'categories', 'searchTypes', 'entryTypes']));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Gallib\Macope\App\Http\Requests\CategorizationRequest  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(CategorizationRequest $request, $id)
    {
        $categorization = Categorization::findOrFail($id);

        $categorization->update($request->all());
<commit_msg>sort by alphabetical order (closes #23)<commit_after><?php

namespace Gallib\Macope\App\Http\Controllers;

use App\Http\Controllers\Controller;
use Gallib\Macope\App\Categorization;
use Gallib\Macope\App\Category;
use Gallib\Macope\App\Http\Requests\CategorizationRequest;

class CategorizationController extends Controller
{

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $categorizations = Categorization::with('category.typeCategory')->get();

        return view('macope::categorizations.index', compact(['categorizations']));
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $categories     = Category::with('typeCategory')->get()->sortBy('name')->pluck('name_with_type_category', 'id');
        $categorization = new Categorization();
        $searchTypes    = array_combine($categorization->getSearchTypes(), $categorization->getSearchTypes());
        $entryTypes     = array_combine($categorization->getEntryTypes(), $categorization->getEntryTypes());

        return view('macope::categorizations.create', compact(['categories', 'searchTypes', 'entryTypes']));
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Gallib\Macope\App\Http\Requests\CategorizationRequest  $request
     * @return \Illuminate\Http\Response
     */
    public function store(CategorizationRequest $request)
    {
        $categorization = Categorization::create($request->all());

        return redirect()
            ->route('categorizations.index')
            ->withSuccess(['success' => 'The categorization has been added']);

    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $categorization = Categorization::findOrFail($id);

        return view('macope::categorizations.show', compact(['categorization']));
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        $categorization = Categorization::findOrFail($id);
        $categories     = Category::with('typeCategory')->get()->sortBy('name')->pluck('name_with_type_category', 'id');
        $searchTypes    = array_combine($categorization->getSearchTypes(), $categorization->getSearchTypes());
        $entryTypes     = array_combine($categorization->getEntryTypes(), $categorization->getEntryTypes());

        return view('macope::categorizations.edit', compact(['categorization', 'categories', 'searchTypes', 'entryTypes']));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Gallib\Macope\App\Http\Requests\CategorizationRequest  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(CategorizationRequest $request, $id)
    {
        $categorization = Categorization::findOrFail($id);

        $categorization->update($request->all());

{'fraction_non_alphanumeric': 0.13881401617250674, 'fraction_numerical': 0.0002994908655286014, 'mean_word_length': 3.0041966426858515, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, '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': '526272', 'n_tokens_mistral': 1889, 'n_tokens_neox': 1961, 'n_words': 347}