- /**
- * @throws ValidationException
- * @throws Exception
- */
- protected function getValidatedModelFromRequest(Request $request): Entity
- {
- $modelInfo = $this->validate($request, [
- 'type' => ['required', 'string'],
- 'id' => ['required', 'integer'],
- ]);
-
- if (!class_exists($modelInfo['type'])) {
- throw new Exception('Model not found');
- }
-
- /** @var Model $model */
- $model = new $modelInfo['type']();
- if (!$model instanceof Entity) {
- throw new Exception('Model not an entity');
- }
+ $requestData = $this->validate($request, array_merge([
+ 'level' => ['required', 'string'],
+ ], $entityHelper->validationRules()));