public function execute() { if ($this->artisan->confirm("Create Admin user now? (requires working db connection)", true)) { $this->artisan->info("Create an Admin user"); $user['name'] = $this->artisan->ask("Administrator's name"); $user['email'] = $this->artisan->ask("Administrator email address"); $matches = false; while (!$matches) { $user['password'] = $this->artisan->secret("Administrator password"); $user['password_confirmation'] = $this->artisan->secret("Confirm password"); $matches = $user['password'] === $user['password_confirmation']; } $user['password'] = bcrypt($user['password']); unset($user['password_confirmation']); // Persist the user $admin = User::create($user); $admin->admin = true; $admin->save(); $this->artisan->comment("Created admin user {$admin->email}"); } }
/** * @param Request $request */ public function store(Request $request) { User::create($request->all()); }
/** * @param UserCreateRequest $request * @return \Illuminate\Http\RedirectResponse */ public function store(UserCreateRequest $request) { $user = User::create($this->buildUserFromRequest($request)); return redirect()->route('admin::users.index'); }
/** * Store a newly created user in storage. * * @param \Flashtag\Api\Http\Requests\CreateUserRequest $request * @return \Dingo\Api\Http\Response */ public function store(CreateUserRequest $request) { $user = User::create(['email' => $request->get('email'), 'name' => $request->get('name'), 'password' => bcrypt($request->get('password'))]); return $this->response->item($user, new UserTransformer()); }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]); }