<?php

namespace App\Http\Controllers;

use App\Models\Category;

class CategoryController extends Controller
{
    public function show($slug)
    {
        $category = Category::where('slug', $slug)->firstOrFail();
        $products = $category->products()->orderByDesc('rating')->paginate(12);

        return view('category.show', compact('category', 'products'));
    }
}
