validated(); if ($this->categoryRepository->update($category, $validate)) { return back() ->with('success', 'Zaktualizowano kategorię!'); } return back() ->with(['error', 'Wystąpił błąd podczas aktualizacji!']); } public function store(CategoryRequest $request) { $category = $this->categoryRepository->create($request->validated()); return redirect() ->route('admin.category.update', compact('category')) ->with('message', 'Utworzono kategorię!'); } public function create(): InertiaResponse { return inertia('Categories/Create'); } public function edit(Category $category): InertiaResponse { return inertia('Categories/Edit', compact('category')); } public function delete(Category $category): InertiaResponse { return inertia('Categories/ConfirmDelete', compact('category')); } public function destroy(Category $category): RedirectResponse { $name = $category->name; $category->delete(); return redirect() ->route('admin.home') ->with('info', 'Usunięto kategorię "'. $name .'"'); } }