/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ public function create(array $data) { if (SiteConstants::isManager($data["user_type"])) { $userType = BasicSiteRepository::getManagerTypes()[$data["managerType"]]; return User::create(['username' => $data['username'], 'password' => $data['password'], 'active' => 0, 'user_type' => $userType, 'management_level' => $data['management_level'], 'sport_type' => $data['sport_type'], 'profile_image_path' => $data['profile_image_path'], 'confirmation_token' => bcrypt(time())]); } else { if (SiteConstants::isTalent($data["user_type"])) { return User::create(['username' => $data['username'], 'password' => $data['password'], 'active' => 0, 'user_type' => $data['user_type'], 'management_level' => $data['management_level'], 'sport_type' => $data['sport_type'], 'profile_image_path' => $data['profile_image_path'], 'confirmation_token' => bcrypt(time())]); } } }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ public function create(array $data) { if (SiteConstants::isManager($data["user_type"])) { $userType = BasicSiteRepository::getManagerTypes()[$data["managerType"]]; $user = null; $user = DB::transaction(function () use($data, $user, $userType) { $user = User::create(['username' => $data['username'], 'password' => $data['password'], 'active' => 0, 'user_type' => $userType, 'management_level' => $data['management_level'], 'sport_type' => $data['sport_type'], 'profile_image_path' => $data['profile_image_path'], 'confirmation_token' => bcrypt(time())]); $user->managerProfile()->create(['first_name' => '', 'middle_name' => '', 'last_name' => '']); return $user; }); return $user; } else { if (SiteConstants::isTalent($data["user_type"])) { return User::create(['username' => $data['username'], 'password' => $data['password'], 'active' => 0, 'user_type' => $data['user_type'], 'management_level' => $data['management_level'], 'sport_type' => $data['sport_type'], 'profile_image_path' => $data['profile_image_path'], 'confirmation_token' => bcrypt(time())]); } } }