<commit_before><?php

namespace Yajra\CMS\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Yajra\CMS\Entities\Category;
use Yajra\CMS\Events\CategoryWasViewed;

class CategoryController extends Controller
{
    /**
     * Display an article.
     *
     * @param \Yajra\CMS\Entities\Category $category
     * @param \Illuminate\Http\Request $request
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function show(Category $category, Request $request)
    {
        $category->increment('hits');

        $layout   = $request->query('layout', 'blog');
        $limit    = $request->get('limit', $layout == 'list' ? 10 : 5);
        $articles = $category->articles()->paginate($limit);

        $path = null;
        if ($layout === 'list') {
            $path .= '?layout=list';
            $articles->setPath($path);
        }

        if ($request->has('limit')) {
            $path .= '&limit=' . $limit;
            $articles->setPath($path);
        }

        event(new CategoryWasViewed($category));

        return view("category.$layout", compact('category', 'articles', 'limit'));
    }
}<commit_msg>Use simple pagination.<commit_after><?php

namespace Yajra\CMS\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Yajra\CMS\Entities\Category;
use Yajra\CMS\Events\CategoryWasViewed;

class CategoryController extends Controller
{
    /**
     * Display an article.
     *
     * @param \Yajra\CMS\Entities\Category $category
     * @param \Illuminate\Http\Request $request
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function show(Category $category, Request $request)
    {
        $category->increment('hits');

        $layout   = $request->query('layout', 'blog');
        $limit    = $request->get('limit', $layout == 'list' ? 10 : 5);
        $articles = $category->articles()->simplePaginate($limit);

        $path = null;
        if ($layout === 'list') {
            $path .= '?layout=list';
            $articles->setPath($path);
        }

        if ($request->has('limit')) {
            $path .= '&limit=' . $limit;
            $articles->setPath($path);
        }

        event(new CategoryWasViewed($category));

        return view("category.$layout", compact('category', 'articles', 'limit'));
    }
}
{'fraction_non_alphanumeric': 0.1639549436795995, 'fraction_numerical': 0.0025031289111389237, 'mean_word_length': 2.6333333333333333, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '966905', 'n_tokens_mistral': 723, 'n_tokens_neox': 714, 'n_words': 132}