get('category_id')) { return false; } $category = Category::find($request->get('category_id')); // Check if the category belongs to the user if ($category->user_id !== auth()->user()->id) { return false; } return true; } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { return [ 'category_id' => 'required', ]; } }