本文整理汇总了PHP中App\Model\User::save方法的典型用法代码示例。如果您正苦于以下问题:PHP User::save方法的具体用法?PHP User::save怎么用?PHP User::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Model\User
的用法示例。
在下文中一共展示了User::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: userList
/**
Method to get information about the logged in user
@param void
@return view
*/
public function userList()
{
if (!Auth::check()) {
return Redirect::to('/');
}
$message = '';
if (Request::isMethod('post')) {
$data = Input::except('_token');
$password = Hash::make(Input::get('password'));
$user = new User();
$user->name = Input::get('name');
$user->email = Input::get('email');
$user->password = $password;
$username = Input::get('name');
$userEmail = Input::get('email');
if ($user->save()) {
try {
Mail::send('emails.welcome', ['userEmail' => $username], function ($m) use($userEmail, $username) {
$m->to($userEmail, $username)->subject('Express Rental');
});
} catch (Exception $ex) {
}
$message = 'Added Successfully';
return Redirect::to('/users/list')->with('message', $message);
} else {
$message = 'Addition not Successfully';
return Redirect::to('/users/list')->withErrors('message', $message);
}
} else {
$allUserInfo = DB::table('users')->orderBy('users.id', 'DESC')->paginate(5);
return view('Home.list')->with(compact('allUserInfo'));
}
}
示例2: emailReminder
/**
* @testdox Requesting a password reminder adds an item to the Mail Queue.
* @test
*/
public function emailReminder()
{
$user = new User(['username' => 'test']);
$user->save();
$user->sendPasswordReminder();
$this->assertEquals(1, QueuedEmail::count());
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @param Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$user = new User($request->all());
$user->email = $user->account . env('DOMAIN');
$user->password = bcrypt($user->password);
$user->save();
return $this->redirectWithSuccessFlash('user', "您已經新增了使用者<b>{$user->username}</b>");
}
示例4: create
/**
* Create and save a new user.
*
* @param array
*/
public function create()
{
// Validate input
$params = array('username' => $this->app->request->post('username'), 'email_address' => $this->app->request->post('email_address'), 'password_hash' => Password::hash($this->app->request->post('password')));
$user = new User($params);
$user->save();
$this->app->redirectTo('home');
}
示例5: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(StoreRequest $request)
{
//
$users = new User();
$users->fill(['name' => $request->name, 'email' => $request->email]);
//var_dump($users); die;
$users->save();
return redirect()->action('UserController@index');
}
示例6: save
/**
* Saves a user in the database.
*
* @param string $name
* @param string $username
* @param string $password
* @param string $role
*
* @return Response
*/
public static function save($name, $username, $password, $role)
{
$user = new User();
$user->name = $name;
$user->username = $username;
$user->password = $password;
$user->role = $role;
$user->save();
}
示例7: registerUser
public function registerUser($name, $email, $password)
{
$user = new User();
$user->password = is_null($password) ? null : bcrypt($password);
$user->email = $email;
$user->save();
$profile = new Profile();
$profile->name = $name;
$profile->user_id = $user->id;
$profile->description = "";
$profile->save();
return $user;
}
示例8: userData
public function userData($userData, $userId)
{
$user = User::find($userId);
//Check if user exist
if (!$user) {
$user = new User();
}
$user->name = $userData['name'];
$user->email = $userData['email'];
$user->password = Hash::make($userData['password']);
$user->save();
return $user;
}
示例9: postRegister
public function postRegister(Request $request)
{
$time = time();
$user = new UserModel();
$user->usr_name = $request->input('usr_name');
$user->usr_email = $request->input('usr_email');
$user->usr_password = Hash::make($request->input('usr_password'));
$user->usr_access_token = md5(uniqid($time, $request->input('usr_email')));
$user->usr_reset_token = md5(uniqid($time, $request->input('usr_email')));
$user->usr_active_fg = true;
$user->rol_id = 1;
if (!$user->save()) {
return 'error';
}
}
示例10: register
/**
* Register an account
* POST
*
* @param Request $request
* @return Response
*/
public function register(Request $request)
{
$this->validate($request, ['login' => 'required|min:5|alpha_num|unique:accounts,account', 'password' => 'required|min:4', 'mail' => 'required|email', 'username' => 'required|alpha_num|unique:accounts,pseudo', 'question' => 'required', 'answer' => 'required', 'cu' => 'required', 'rules' => 'required']);
$user = new UserManager();
$user->account = $request->login;
$user->pass = $request->password;
$user->email = $request->mail;
$user->pseudo = $request->username;
$user->level = 0;
$user->question = $request->question;
$user->reponse = $request->answer;
$user->code = $this->_generateCode(24);
$user->save();
Auth::login($user);
return redirect()->route('join');
}
示例11: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
$validator = Validator::make($request->all(), ['first_name' => 'required|alpha|max:255', 'last_name' => 'required|alpha|max:255', 'email' => 'required|email|unique:users|max:255', 'password' => 'required|min:6']);
if ($validator->fails()) {
return Redirect::to(route('user.create'))->withErrors($validator)->withInput();
} else {
$user = new User();
$user->first_name = $request->first_name;
$user->last_name = $request->last_name;
$user->email = $request->email;
$user->password = bcrypt($request->password);
$user->save();
Session::flash('info', 'Successfully created');
return Redirect::to(route('user.index'));
}
}
示例12: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request, Guard $auth)
{
$v = \Validator::make($request->all(), ['email' => 'required|email', 'username' => 'required|max:255', 'password' => 'required|confirmed']);
if ($v->fails()) {
return redirect()->back()->withErrors($v->errors());
}
$user = new User();
if (User::whereEmail($request->input('email'))->count() < 1 && User::whereUsername($request->input('username'))->count() < 1) {
$user->username = $request->input('username');
$user->email = $request->input('email');
$user->password = \Hash::make($request->input('password'));
if ($user->save()) {
\Auth::login($user);
return redirect()->route('tasks.index');
}
}
return redirect()->back()->with("NOTIF_INFO", "Email or Username have been registered");
}
示例13: register
function register(Request $request)
{
$name = $request->input('name');
$email = $request->input('email');
$password = sha1($request->input('password'));
$exist_user = User::where('email', $email)->count();
if ($exist_user == 0) {
$user = new User();
$user->name = $name;
$user->email = $email;
$user->password = $password;
$user->save();
$result = array('success' => true, 'message' => 'register success.');
} else {
$result = array('success' => false, 'message' => 'email is existing.');
}
return $result;
}
示例14: register
public static function register($postData)
{
$user = User::where('email', $postData['email'])->first();
if ($user) {
return false;
} else {
$postData['password'] = md5($postData['password']);
unset($postData['retype']);
$newUser = new User();
foreach ($postData as $key => $value) {
$newUser->{$key} = $value;
}
$newUser->save();
unset($newUser['password']);
return $newUser;
}
return false;
}
示例15: registerSaveAction
public function registerSaveAction($request, $response)
{
$this->validator->rule('required', ['username', 'email', 'password', 'first_name', 'last_name']);
$this->validator->rule('email', 'email');
if ($this->validate()) {
$input = $request->getParsedBody();
$user = new User();
$user->username = $input['username'];
$user->email = $input['email'];
$user->password = password_hash($input['password'], PASSWORD_DEFAULT);
$user->first_name = $input['first_name'];
$user->last_name = $input['last_name'];
$save = $user->save();
if ($save) {
$this->flash->addMessage('success', 'Register Success');
}
}
return $response->withRedirect($this->router->pathFor('registerPage'));
}