latest() ->paginate(10, ['id', 'name', 'slug', 'description', 'color', 'created_at']); return view('category.index', [ 'categories' => $categories, ]); } /** * Show the form for creating a new category. */ public function create(): View { return view('category.create'); } /** * Store a newly created category. */ public function store(StoreCategoryRequest $request): RedirectResponse { Category::query()->create($request->validated()); return redirect() ->route('category.index') ->with('status', 'category-created'); } /** * Show the form for editing the specified category. */ public function edit(Category $category): View { return view('category.edit', [ 'category' => $category, ]); } /** * Update the specified category. */ public function update(UpdateCategoryRequest $request, Category $category): RedirectResponse { $category->update($request->validated()); return redirect() ->route('category.edit', $category) ->with('status', 'category-updated'); } /** * Remove the specified category. */ public function destroy(Category $category): RedirectResponse { $category->delete(); return redirect() ->route('category.index') ->with('status', 'category-deleted'); } }