/**
* @param array $data
* @param bool $provider
* @return static
*/
public function create(array $data, $provider = false)
{
$user = self::MODEL;
$user = new $user();
$user->name = $data['name'];
$user->email = $data['email'];
$user->confirmation_code = md5(uniqid(mt_rand(), true));
$user->status = 1;
$user->password = $provider ? null : bcrypt($data['password']);
$user->confirmed = $provider ? 1 : (config('access.users.confirm_email') ? 0 : 1);
DB::transaction(function () use($user) {
if (parent::save($user)) {
/**
* Add the default site role to the new user
*/
$user->attachRole($this->role->getDefaultUserRole());
}
});
/**
* If users have to confirm their email and this is not a social account,
* send the confirmation email
*
* If this is a social account they are confirmed through the social provider by default
*/
if (config('access.users.confirm_email') && $provider === false) {
$user->notify(new UserNeedsConfirmation($user->confirmation_code));
}
/**
* Return the user object
*/
return $user;
}