validate([ 'keyword' => 'required|string|max:255', 'category_id' => 'required|exists:categories,id', ]); CategoryRule::create([ ...$validated, 'user_id' => auth()->id(), ]); return redirect()->back(); } public function destroy(CategoryRule $categoryRule) { if ($categoryRule->user_id !== auth()->id()) { abort(403); } $categoryRule->delete(); return redirect()->back(); } }