public function register(Request $request, AppMailer $mailer) { $input = $request->json()->all(); $validator = $this->validator($input); if ($validator->fails()) { return response()->json($validator->errors(), 400); } // Check if the user already exists if (!$this->users->userExists($input['email'])) { // Rework the input slightly to match the expected graph format $input = $this->restructureUserInput($input); $user = $this->users->store($input); $mailer->sendRegistrationToAdmin($user); return response()->json(['message' => 'Uw registratie is doorgevoerd, een admin moet deze echter wel nog goedkeuren. Hou ook uw SPAM folder in uw inbox in de gaten, de bevestiging kan bij sommige daar terecht komen.']); } else { return response()->json(['email' => ['Een gebruiker met dit email adres is reeds geregistreerd.']], 400); } }