'Updated Email', 'message' => 'Successfully updated email' ]; } public function __construct(CreateUserProcessor $createUserProcessor, AssignEmployeeProcessor $assignEmployeeProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor) { $this->createUserProcessor = $createUserProcessor; $this->assignEmployeeProcessor = $assignEmployeeProcessor; $this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor; } public function logic(Request $request): JsonResponse { $new_email = $request->input('name'); $user = Auth::user(); $company = $user->company()->first(); $user->email = $new_email; request()->request->add([ 'name' => $user->name, 'email' => $new_email, 'password' => $user->getAuthPassword(), 'password_confirmation' => $user->getAuthPassword() ]); /** @var User $user */ $user = $this->createUserProcessor->execute($request, RoleTypes::USER, ApprovalStatus::PENDING_VERIFICATION); $Object = new EmploymentObject($company, $user); $this->assignEmployeeProcessor->execute($Object); $this->generateEmailVerificationAttemptProcessor->execute($user); return $this->response([ 'message' => 'test' ]); } }