diff --git a/app/Classes/Modules/Accounts/DataTransferObjects/RegistrationObject.php b/app/Classes/Modules/Accounts/DataTransferObjects/RegistrationObject.php new file mode 100644 index 00000000..533979b0 --- /dev/null +++ b/app/Classes/Modules/Accounts/DataTransferObjects/RegistrationObject.php @@ -0,0 +1,99 @@ +name = $name; + $this->email = $email; + $this->password = $password; + $this->passwordConfirmation = $passwordConfirmation; + $this->type = $type; + $this->status = $status; + } + + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * @return string + */ + public function getEmail(): string + { + return $this->email; + } + + /** + * @return string + */ + public function getPassword(): string + { + return $this->password; + } + + /** + * @return string + */ + public function getPasswordConfirmation(): string + { + return $this->passwordConfirmation; + } + + /** + * @return int + */ + public function getType(): int + { + return $this->type; + } + + /** + * @return int + */ + public function getStatus(): int + { + return $this->status; + } + + + + +} \ No newline at end of file diff --git a/app/Classes/Modules/Accounts/Processors/CreateUserProcessor.php b/app/Classes/Modules/Accounts/Processors/CreateUserProcessor.php new file mode 100644 index 00000000..5dcb7e8d --- /dev/null +++ b/app/Classes/Modules/Accounts/Processors/CreateUserProcessor.php @@ -0,0 +1,54 @@ +canRegisterUser = $canRegisterUser; + $this->createsUser = $createsUser; + } + + + /** + * @param Request $request + * @param $roleType + * @param $status + * @return Model + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException + * @throws \App\Classes\Exceptions\RequestValidationException + */ + public function execute(Request $request, $roleType, $status): Model { + + $userObject = new RegistrationObject($request->input('name'), $request->input('email'), + $request->input('password'), $request->input('password_confirmation'), + $roleType, $status); + + $this->canRegisterUser->passes($userObject); + + /** @var User $user_query */ + return $this->createsUser->execute($userObject); + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Accounts/Services/CreatesUser.php b/app/Classes/Modules/Accounts/Services/CreatesUser.php new file mode 100644 index 00000000..f18ba8f8 --- /dev/null +++ b/app/Classes/Modules/Accounts/Services/CreatesUser.php @@ -0,0 +1,27 @@ +name = $object->getName(); + $model->email = $object->getEmail(); + $model->password = bcrypt($object->getPassword()); + $model->type = $object->getType(); + $model->status = $object->getStatus(); + + return $this->handler($model); + + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Accounts/Standards/Rules/CanRegisterUser.php b/app/Classes/Modules/Accounts/Standards/Rules/CanRegisterUser.php new file mode 100644 index 00000000..d0720d1c --- /dev/null +++ b/app/Classes/Modules/Accounts/Standards/Rules/CanRegisterUser.php @@ -0,0 +1,51 @@ +userValidation = $userValidation; + } + + /** + * @return bool + */ + protected function authorized(): bool + { + // TODO Set Authorization rules + return true; + } + + /** + * @param RegistrationObject $object + * @return bool + * @throws \App\Classes\Exceptions\RequestValidationException + */ + protected function validators($object): bool + { + return $this->userValidation->validate($object); + } + + /** + * @param RegistrationObject $object + * @return bool + */ + protected function criteria($object): bool + { + return true; + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Accounts/Standards/Validators/UserRegistrationValidation.php b/app/Classes/Modules/Accounts/Standards/Validators/UserRegistrationValidation.php new file mode 100644 index 00000000..673b7961 --- /dev/null +++ b/app/Classes/Modules/Accounts/Standards/Validators/UserRegistrationValidation.php @@ -0,0 +1,49 @@ + $object->getName(), + 'email' => $object->getEmail(), + 'password' => $object->getPassword(), + 'password_confirmation' => $object->getPasswordConfirmation(), + 'type' => $object->getType(), + 'status' => $object->getStatus(), + ]; + } + + /** + * @return array + */ + protected function rules(): array + { + return [ + 'name' => 'required', + 'email' => 'required|email|max:255|unique:users,email', + 'password' => 'required|min:6|confirmed', + 'type' => 'required', + 'status' => 'required' + ]; + } + + /** + * @return array + */ + protected function messages(): array + { + return []; + } +} \ No newline at end of file diff --git a/app/Classes/ValueObjects/Constants/ApprovalStatus.php b/app/Classes/ValueObjects/Constants/ApprovalStatus.php new file mode 100644 index 00000000..2f6a7a4a --- /dev/null +++ b/app/Classes/ValueObjects/Constants/ApprovalStatus.php @@ -0,0 +1,21 @@ +