本文整理汇总了PHP中app\User::Create方法的典型用法代码示例。如果您正苦于以下问题:PHP User::Create方法的具体用法?PHP User::Create怎么用?PHP User::Create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\User
的用法示例。
在下文中一共展示了User::Create方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createUser
function createUser(Request $request)
{
$person = User::Create($request->all());
$person->password = bcrypt($request['password']);
$person->save();
return $person;
}
示例2: register
/**
* Register a new user or we can say sign up
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
public function register(RegisterRequest $request)
{
$rqst = new rqst();
$data = $request->all();
$data['password'] = bcrypt($data['password']);
$users = User::Create($data);
if (\Auth::attempt(['username' => $data['username'], 'password' => $request->get('password')])) {
User::where('id', '=', \Auth::user()->id)->update(array('logged_in' => '1'));
\Flash::message('You are successfully registered.');
return \Redirect::action('HomeController@dashboard');
//,compact('users'));
}
}
示例3: findByUsernameOrCreate
public function findByUsernameOrCreate($userData)
{
$user = User::where('email', $userData->email)->first();
if (count($user) > 0) {
return $user;
}
$user = User::Create(['firstname' => !empty($userData->user['first_name']) ? $userData->user['first_name'] : $userData->nickname, 'lastname' => !empty($userData->user['last_name']) ? $userData->user['last_name'] : '', 'email' => !empty($userData->email) ? $userData->email : '', 'status' => 1]);
if (!empty($user) && !empty($userData->avatar)) {
$name = time() . '.jpg';
$path = public_path() . '/files/avatar/';
File::makeDirectory($path, $mode = 0777, true);
Image::make($userData->avatar)->save($path . $name);
$user->avatar = $name;
$user->save();
}
return $user;
}
示例4: findSocialiteIdOrCreate
public function findSocialiteIdOrCreate($userData)
{
if ($userData->socialiteName == 'weibo') {
$user = User::where('weibo_id', '=', $userData->weibo_id)->first();
if (!$user) {
$user = User::Create(['nickname' => $userData->input('nickname'), 'avatar' => $userData->input('avatar'), 'weibo_id' => $userData->input('weibo_id'), 'signature' => $userData->input('signature'), 'email' => $userData->input('email'), 'sex' => $userData->input('sex')]);
$location = $user->location();
$location->firstOrCreate(['country' => $userData->input('country'), 'province' => $userData->input('province'), 'city' => $userData->input('city')]);
}
} elseif ($userData->socialiteName == 'weixin') {
$user = User::where('weixin_id', '=', $userData->weixin_id)->first();
if (!$user) {
$user = User::Create(['nickname' => $userData->input('nickname'), 'avatar' => $userData->input('avatar'), 'weixin_id' => $userData->input('weixin_id'), 'signature' => $userData->input('signature'), 'email' => $userData->input('email'), 'sex' => $userData->input('sex')]);
$location = $user->location();
$location->firstOrCreate(['country' => $userData->input('country'), 'province' => $userData->input('province'), 'city' => $userData->input('city')]);
}
}
return User::with('location')->find($user->id);
}
示例5: findByUsernameOrCreate
public function findByUsernameOrCreate($userData)
{
$users = User::where('user_email', '=', $userData->email)->first();
if (!$users) {
//email not used
if ($userData->nickname == null) {
$user = User::Create(['user_firstname' => $userData->name, 'user_email' => $userData->email, 'avatar' => $userData->avatar, 'role_id' => 3, 'provider_id' => $userData->id]);
} else {
$user = User::Create(['user_firstname' => $userData->nickname, 'user_email' => $userData->email, 'avatar' => $userData->avatar, 'role_id' => 3, 'provider_id' => $userData->id]);
}
return $user;
} else {
$users = User::where('user_email', '=', $userData->email)->where('provider_id', '=', $userData->id)->first();
if ($users) {
//email used with same provider id
return $users;
} else {
//email is used with different provider id
//cannot sign up with same email because different provider id(email cannot be duplicate user)
$user = false;
return $user;
}
}
}
示例6: postRegister
public function postRegister(Request $request)
{
$user = ["remember_token" => Request::get('_token'), "name" => Request::get('name'), "password" => hash::make(Request::get('password')), "email" => Request::get('email'), "role_id" => 1];
User::Create($user);
}
示例7: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
User::Create(['email' => 'jyrone.parker@gmail.com', 'password' => bcrypt('n1nt3nd0'), 'name' => 'Jyrone Parker', 'api_token' => str_random(60)]);
}
示例8: create
public function create(array $data)
{
return User::Create(['name' => $data['name'], 'password' => Hash::make($data['password']), 'email' => $data['email'], 'signature' => $data['signature'], 'telephone' => $data['telephone'], 'sex' => $data['sex'], 'is_banned' => $data['is_banned']]);
}
示例9: create
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
public function create(array $data)
{
return User::Create(['first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'username' => $data['username'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'phone' => $data['phone']]);
}
示例10: userCreateOrUpdate
/**
* Create a new user or update an existing one.
*
* @param array $credentials
* @param sting $id
* @return $this
*/
protected function userCreateOrUpdate($credentials, $id)
{
$user = ['first_name' => $credentials['first_name'], 'last_name' => $credentials['last_name'], 'username' => $credentials['username'], 'password' => bcrypt($credentials['password']), 'email' => $credentials['email'], 'title' => $credentials['title'], 'group' => $credentials['group'], 'ers_id' => $credentials['ers_id']];
if (!$id) {
User::Create($user);
}
if ($id) {
User::find($id)->update($user);
}
}