本文整理汇总了PHP中User::fill方法的典型用法代码示例。如果您正苦于以下问题:PHP User::fill方法的具体用法?PHP User::fill怎么用?PHP User::fill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User::fill方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
public function store()
{
$data = Input::all();
if (isset($data['phone_number'])) {
$data['phone_number'] = str_replace(' ', '', $data['phone_number']);
}
if (isset($data['work_phone'])) {
$data['work_phone'] = str_replace(' ', '', $data['work_phone']);
}
$u = new User();
$a = false;
$role_id = Input::get('role_id');
if ($role_id == Config::get('constants.ROLE_BUYER')) {
$a = new Buyer();
$u->status = 2;
$data['skip_verification'] = true;
} elseif ($role_id == Config::get('constants.ROLE_SELLER')) {
$a = new Seller();
} elseif ($role_id == Config::get('constants.ROLE_BROKER')) {
$a = new Broker();
} else {
//we don't know this role or attempt to register unlisted role
unset($data['role_id']);
}
if (!isset($data['password']) || $data['password'] == "") {
$pwd = Str::random(10);
$data['password'] = $data['password_confirmation'] = $pwd;
}
if ($u->validate($data)) {
if ($a && $a->validate($data)) {
if (isset($pwd)) {
Session::set('validate_password', true);
}
$data['password'] = Hash::make($data['password']);
$u->fill($data);
$code = Str::random(10);
$u->verification_code = $code;
$data['verification_code'] = $code;
$u->save();
$data['user_id'] = $u->id;
$a->fill($data);
$a->save();
$email = $u->email;
if (isset($data['skip_verification'])) {
$data['url']['link'] = url('/');
$data['url']['name'] = 'Go to CompanyExchange';
Mail::queue('emails.templates.welcome', $data, function ($message) use($email) {
$message->from('listings@ng.cx', 'CompanyExchange');
$message->to($email);
$message->subject('Welcome to CompanyExchange');
});
} else {
Mail::queue('emails.templates.progress', $data, function ($message) use($email) {
$message->from('listings@ng.cx', 'CompanyExchange');
$message->to($email);
$message->subject('Welcome to CompanyExchange');
});
}
if ($role_id == Config::get('constants.ROLE_BUYER')) {
Auth::loginUsingId($u->id);
Alert::success('Welcome to CompanyExchange. Please feel free to browse through our listings and contact sellers you would like to buy from.', 'Congratulations');
return Redirect::to('search?q=')->withSuccess("Welcome {$u->first_name}. Use the form on the left to search for listed businesses or browse the most recent listings below");
}
return Redirect::to('login')->withSuccess('Registration successful. Please check email to activate your account');
}
Input::flash();
return View::make('users.register')->withErrors($a ? $a->getValidator() : []);
}
Input::flash();
return View::make('users.register')->withErrors($u->getValidator());
}
示例2: createUser
public function createUser()
{
$options = $this->option();
$this->info('Creating the developer account');
if (!$options['name']) {
$options['name'] = $this->ask('What is your name?');
}
if (!$options['email']) {
$options['email'] = $this->ask('What is your email?');
}
if (!$options['password']) {
$p1 = ' ';
$p2 = '';
while ($p1 !== $p2) {
$p1 = $this->secret('Type a password');
$p2 = $this->secret('Repeat the password');
if ($p1 !== $p2) {
$this->error('Passwords doesn\'t match, try again');
}
}
$options['password'] = $p1;
}
$user = ['name' => $options['name'], 'email' => $options['email'], 'role' => 'dev'];
try {
$model = new \User();
$model->fill($user);
$model->password = \Hash::make($options['password']);
$model->isValid();
$model->save();
} catch (\Exception $e) {
$this->error('Error creating developer user: "' . $e->getMessage() . '"');
}
}
示例3: run
public function run()
{
$user = new User();
$user->fill(array('email' => '', 'nickname' => '', 'activated' => '1'));
$user->password = Hash::make('admin');
$user->save();
}
示例4: postRegistration
public function postRegistration()
{
if ($this->isPostRequest()) {
$validator = $this->getRegistrationValidator();
if ($validator->passes()) {
$credentials = $this->getRegistrationCredentials();
$user = new User();
//Take care, only mass assignable columns are fillable, check User model
$user->fill($credentials);
if ($user->save()) {
$status = 201;
$data = array('status' => $status, 'success' => true, 'message' => 'User sucessfully created');
$response = MyResponse::json($data, $status);
return $response;
} else {
$status = 200;
$data = array('status' => $status, 'success' => false, 'message' => 'User unsucessfully updated');
$response = MyResponse::json($data, $status);
return $response;
}
} else {
$status = 200;
$data = array('status' => $status, 'success' => false, 'message' => $validator->messages()->toArray());
$response = MyResponse::json($data, $status);
return $response;
}
} else {
}
}
示例5: saveUser
public function saveUser()
{
$input = Input::all();
$input['password'] = Hash::make($input['password']);
$user = new User();
$user->fill($input);
$user->save();
return $user;
}
示例6: postRegister
public function postRegister()
{
$rules = User::$validation;
$validation = Validator::make(Input::all(), $rules);
if ($validation->fails()) {
return Redirect::to('users/register')->withErrors($validation)->withInput();
}
$user = new User();
$user->fill(Input::all());
$id = $user->register();
return $this->getMessage("Регистрация почти завершена. Вам необходимо подтвердить e-mail, указанный при регистрации, перейдя по ссылке в письме.");
}
示例7: store
public function store()
{
$data = Input::all()['user'];
$user = new User();
if ($user->isValid($data)) {
$data['password'] = Hash::make($data['password']);
$user->fill($data);
$user->save();
return Redirect::route('users.index');
}
return Redirect::route('users.create')->withInput()->withErrors($user->errors);
}
示例8: postRegister
public function postRegister()
{
$validator = Validator::make(Input::all(), array('name' => array('required', 'min:5'), 'email' => array('required', 'email', 'unique:users'), 'password' => array('required', 'confirmed')));
if ($validator->passes()) {
$user = new User();
$user->fill(Input::all());
$id = $user->register();
return $this->getMessage("Регистрация почти завершена. Вам необходимо подтвердить e-mail, указанный при регистрации, перейдя по ссылке в письме.");
} else {
return Redirect::to('auth/register')->with('error', 'Please correct the following errors:')->withErrors($validator)->withInput();
}
return;
}
示例9: store
public function store()
{
// Get form data, create new user
// Hacky, I know, but had to do this because of Sentry
$user_data = Input::all();
$user = new User();
$user->fill($user_data);
// TODO: If we need to do confirmation, then stop doing this below
$user->confirmed = 1;
if ($user->save()) {
return Redirect::to('admin/users/' . $user->id . '/edit')->with('success_message', trans('admin.create_success'));
} else {
return Redirect::to('admin/users/create')->withInput(Input::except('password'))->withErrors($user->errors());
}
}
示例10: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$user = new User();
$user->unguard();
$user->fill(Input::only('username', 'email', 'password', 'rights', 'first_name', 'last_name', 'student_number'));
if ($user->validate()) {
$user->password = Hash::make(Input::get('password'));
$user->save();
} else {
$user->password = null;
// Don't send the password back over the wire
return View::make('users.create', ['user' => $user])->withErrors($user->validator());
}
return Redirect::to(route('settings.index'))->with('message', ['content' => 'Gebruiker met succes aangemaakt!', 'class' => 'success']);
}
示例11: action_register
public function action_register()
{
$method = Request::method();
if ($method == 'POST') {
// get the username and password from the POST
// data using the Input class
$username = Input::get('username');
$email = Input::get('email');
$password = Input::get('password');
$role = 1;
$active = true;
if (empty($username) || empty($password)) {
return Redirect::to('account/register')->with('register_errors', true);
} else {
$arr = array('username' => $username, 'email' => $email, 'password' => Hash::make($password), 'role' => $role, 'active' => $active);
$rules = array('username' => 'unique:users,username|required|min:1|max:20', 'password' => 'required', 'email' => 'unique:users,email|required');
// make the validator
$v = Validator::make($arr, $rules);
if ($v->fails()) {
// redirect back to the form with
// errors, input and our currently
// logged in user
return Redirect::to('account/register')->with('user', Auth::user())->with_errors($v)->with_input();
}
$user = new User();
$user->fill($arr);
$result = $user->save();
// call Auth::attempt() on the username and password
// to try to login, the session will be created
// automatically on success
if ($result) {
if (Auth::attempt(array('username' => $username, 'password' => $password, 'remember' => true))) {
// it worked, redirect to the admin route
return Redirect::to('/');
} else {
// login failed, show the form again and
// use the login_errors data to show that
// an error occured
return Redirect::to('account/login')->with('login_errors', true);
}
} else {
return Redirect::to('account/register')->with('register_errors', true);
}
}
} else {
return View::make('account.register');
}
}
示例12: postRegister
public function postRegister()
{
// Проверка входных данных
$data = Input::all();
$rules = User::$validation;
$validation = Validator::make($data, $rules);
if ($validation->fails()) {
// В случае провала, редиректим обратно с ошибками и самими введенными данными
return Redirect::to('users/register')->withErrors($validation)->withInput();
}
// Сама регистрация с уже проверенными данными
$user = new User();
$user->fill($data);
$id = $user->register();
// Вывод информационного сообщения об успешности регистрации
return $this->getMessage("Регистрация почти завершена. Вам необходимо подтвердить e-mail, указанный при регистрации, перейдя по ссылке в письме.");
}
示例13: getStoreAdmin
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function getStoreAdmin()
{
$inputs = \Input::all();
$validator = \Validator::make($inputs, ['email' => 'required|email|unique:users', 'password' => 'required|confirmed', 'username' => 'required', 'first_name' => 'required', 'last_name' => 'required']);
$data = ['username' => $inputs['username'], 'first_name' => $inputs['first_name'], 'last_name' => $inputs['last_name'], 'email' => $inputs['email'], 'password' => $inputs['password'] = Hash::make($inputs['password']), 'confirmation_token' => $inputs['confirmation_token'] = sha1(uniqid($inputs['email'], true))];
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput($data);
}
$user = new User();
$user->fill($data);
// $user->is_confirmed = true;
// $user->is_admin = (bool)array_get($data, 'is_admin');
Mail::send('emails.activate', $data, function ($message) use($data) {
$message->to($data['email'])->subject('Please verify your email address');
});
User::create($user);
// return Redirect::to('login')->with('alert', 'Sign up successful, Please check your email.');
return Redirect::route('admin.users.show', ['id' => $user->id])->with('alert-success', 'User was created.');
}
示例14: store
/**
* Store a newly created user in storage.
*
* @return Response
*/
public function store()
{
User::setRules('store');
$data = Input::all();
if (!User::canCreate()) {
return $this->_access_denied();
}
$data['confirmed'] = 1;
$data['roles'] = isset($data['roles']) ? $data['roles'] : [];
$user = new User();
$user->fill($data);
if (!$user->save()) {
return $this->_validation_error($user);
}
$user->roles()->sync($data['roles']);
if (Request::ajax()) {
return Response::json($user, 201);
}
return Redirect::route('users.index')->with('notification:success', $this->created_message);
}
示例15: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//Creamos un nuevo objeto para nuestro nuevo usuario
$user = new User();
//return Input::all();
//Obtenemos la data enviada por el usuario
$data = Input::all();
//
//var_dump($data);
//Revisamos si la data es valida
if ($user->isValid($data)) {
//Si la data es valida se la asignamos al usuario
$user->fill($data);
//Guardamos el usuario
$user->save();
//Y devolvemos una redirección a la acción show para mostrar el usuario
return Redirect::route('admin.users.show', array($user->id));
} else {
// En caso de error regresa a la acción create con los datos y los errores encontrados
return Redirect::route('admin.users.create')->withInput()->withErrors($user->errors);
}
}