1class CategoryController extends Controller
2{
3 public function show($slug)
4 {
5 $category = Category::with('posts')->where('slug', $slug)->firstOrFail();
6
7 if (view()->exists('category.custom.'.$category->slug)) {
8 $view = 'category.custom.'.$category->slug;
9 } else {
10 $view = 'category.show';
11 }
12
13 return view($view, [
14 'category' => $category,
15 ]);
16 }
17}
18