$object->getName(), 'description' => $object->getDescription(), ]; return $data; } /** * @param null|string $type * @return array */ protected function rules(): array { return [ 'name' => [ 'required', function ($attribute, $value, $fail) { // Check if reward name already exists in the database $existingMilestone = Reward::where('name', $value)->first(); if ($existingMilestone) { $fail("The {$attribute} reward name already exists in the database."); } }, ], 'description' => [ 'required', ] ]; } /** * @return array */ protected function messages(): array { return []; } }