本文整理汇总了PHP中App\Repositories\UserRepository::create方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRepository::create方法的具体用法?PHP UserRepository::create怎么用?PHP UserRepository::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Repositories\UserRepository
的用法示例。
在下文中一共展示了UserRepository::create方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* @param CreateUserRequest $request
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function store(CreateUserRequest $request)
{
$user = $this->user->create($request->all());
Flash::success(trans('admin/users/general.status.created'));
// 'User successfully created');
return redirect('/admin/users');
}
示例2: store
/**
* Store a newly created User in storage.
*
* @param CreateUserRequest $request
*
* @return Response
*/
public function store(CreateUserRequest $request)
{
$input = $request->all();
$user = $this->userRepository->create($input);
Flash::success('User saved successfully.');
return redirect(route('users.index'));
}
示例3: register
/**
* Register the user.
*
* @param RegisterRequest $request
* @return $this|\Illuminate\Http\RedirectResponse
*/
public function register(RegisterRequest $request)
{
$success = $this->repository->create($request->all());
if (!$success) {
return redirect()->back()->withErrors(['register_failed' => Lang::get('auth.register_failed')]);
}
return redirect()->route('auth.login')->with(['notice' => Lang::get('auth.register_success')]);
}
示例4: postRegister
/**
* Create user registration.
*
* @param Request $request
* @param AppMailer $mailer
* @return \Illuminate\Http\RedirectResponse
*/
public function postRegister(Request $request, AppMailer $mailer)
{
$this->validate($request, $this->validateRegistrationForm());
$user = $this->users->create($request->all());
if (Auth::attempt($this->getCredentials($request))) {
$mailer->sendEmailVerificationTo($user);
}
return redirect('/');
}
示例5: store
/**
* Store a newly created User in storage.
* POST /users
*
* @param Request $request
*
* @return Response
*/
public function store(Request $request)
{
if (sizeof(User::$rules) > 0) {
$this->validateRequestOrFail($request, User::$rules);
}
$input = $request->all();
$users = $this->userRepository->create($input);
return $this->sendResponse($users->toArray(), "User saved successfully");
}
示例6: store
/**
* @param CreateUserRequest $request
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function store(CreateUserRequest $request)
{
$user = $this->user->create($request->all());
if ($request->get('role')) {
$user->roles()->sync($request->get('role'));
} else {
$user->roles()->sync([]);
}
Flash::success('User successfully created');
return redirect('/users');
}
示例7: store
/**
* Store a newly created User in storage.
*
* @param CreateUserRequest $request
*
* @return Response
*/
public function store(CreateUserRequest $request)
{
$this->authorize('users.manage');
$input = $request->all();
if (!empty($input['password'])) {
$input['password'] = bcrypt($input['password']);
} else {
unset($input['password']);
}
$user = $this->userRepository->create($input);
$user->roles()->sync([$request->get('role')]);
Flash::success('User saved successfully.');
return redirect(route('users.index'));
}
示例8: store
/**
* @param CreateUserRequest $request
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function store(CreateUserRequest $request)
{
$attributes = $request->all();
Audit::log(Auth::user()->id, trans('admin/users/general.audit-log.category'), trans('admin/users/general.audit-log.msg-store', ['username' => $attributes['username']]));
if (array_key_exists('selected_roles', $attributes)) {
$attributes['role'] = explode(",", $attributes['selected_roles']);
}
if ($attributes['role'][0] == '') {
$attributes['role'][0] = "2";
}
// Create basic user.
$user = $this->user->create($attributes);
// Run the update method to set enabled status and roles membership.
$user->update($attributes);
// TODO: Create front end system to manage users and clusters
// TODO: In the meantime, give all users access to every cluster.
$clusters = Cluster::all();
foreach ($clusters as $cluster) {
$user->clusters()->attach($cluster);
}
/*
* Assign the new user's active cluster
*/
$user->activateCluster($attributes['activeCluster']);
/*
* Assign the department
*/
$department = Department::find($attributes['department']);
$department->users()->save($user);
$user->save();
alert()->success(trans('admin/users/general.status.created'));
// 'User successfully created');
return redirect('/admin/users');
}
示例9: store
/**
* @param CreateUserRequest $request
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function store(CreateUserRequest $request)
{
$attributes = $request->all();
if (array_key_exists('selected_roles', $attributes)) {
$attributes['role'] = explode(",", $attributes['selected_roles']);
}
// Create basic user.
$user = $this->user->create($attributes);
// Run the update method to set enabled status and roles membership.
$user->update($attributes);
Flash::success(trans('admin/users/general.status.created'));
// 'User successfully created');
return redirect('/admin/users');
}
示例10: store
/**
* @param CreateUserRequest $request
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function store(CreateUserRequest $request)
{
$this->validate($request, array('username' => 'required|unique:users', 'email' => 'required|unique:users', 'first_name' => 'required', 'last_name' => 'required'));
$attributes = $request->all();
Audit::log(Auth::user()->id, trans('admin/users/general.audit-log.category'), trans('admin/users/general.audit-log.msg-store', ['username' => $attributes['username']]));
if (array_key_exists('selected_roles', $attributes) && !empty($attributes['selected_roles'])) {
$attributes['role'] = explode(",", $attributes['selected_roles']);
} else {
$attributes['role'] = [];
}
// Create basic user.
$user = $this->user->create($attributes);
// Run the update method to set enabled status and roles membership.
$user->update($attributes);
Flash::success(trans('admin/users/general.status.created'));
// 'User successfully created');
return redirect('/admin/users');
}
示例11: store
/**
* Store a newly created resource in storage.
*
* @param UserRequest $request
*
* @return \Illuminate\Http\RedirectResponse
*/
public function store(UserRequest $request)
{
$this->users->create($request->all());
return redirect()->route('admin.users.index');
}
示例12: create
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
return view('back.users.create', $this->user_gestion->create());
}
示例13: createNewUser
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function createNewUser(array $data)
{
$user = $this->repo->create($data);
return $user;
}
示例14: addUser
/**
* Add the User to the Database and Authenticate
* @param Request $request
* @param User $repo
*/
public function addUser(CrateUserRequest $request, User $repo)
{
$role = \App\Role::where('name', 'user')->get()->first();
$user = $repo->create($request->all());
$user->attachRole($role);
Auth::attempt(['email' => $user->email, 'password' => $user->password]);
return redirect()->route()->intended('registration');
}