本文整理匯總了PHP中Images::saveUserGravatar方法的典型用法代碼示例。如果您正苦於以下問題:PHP Images::saveUserGravatar方法的具體用法?PHP Images::saveUserGravatar怎麽用?PHP Images::saveUserGravatar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Images
的用法示例。
在下文中一共展示了Images::saveUserGravatar方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: store
/**
* Store a newly created user in storage.
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$this->checkPermission('users-manage');
$validationRules = ['name' => 'required', 'email' => 'required|email|unique:users,email'];
$authMethod = config('auth.method');
if ($authMethod === 'standard') {
$validationRules['password'] = 'required|min:5';
$validationRules['password-confirm'] = 'required|same:password';
} elseif ($authMethod === 'ldap') {
$validationRules['external_auth_id'] = 'required';
}
$this->validate($request, $validationRules);
$user = $this->user->fill($request->all());
if ($authMethod === 'standard') {
$user->password = bcrypt($request->get('password'));
} elseif ($authMethod === 'ldap') {
$user->external_auth_id = $request->get('external_auth_id');
}
$user->save();
if ($request->has('roles')) {
$roles = $request->get('roles');
$user->roles()->sync($roles);
}
// Get avatar from gravatar and save
if (!config('services.disable_services')) {
$avatar = \Images::saveUserGravatar($user);
$user->avatar()->associate($avatar);
$user->save();
}
return redirect('/settings/users');
}
示例2: registerNew
/**
* Creates a new user and attaches a role to them.
* @param array $data
* @return User
*/
public function registerNew(array $data)
{
$user = $this->create($data);
$this->attachDefaultRole($user);
// Get avatar from gravatar and save
if (!config('services.disable_services')) {
$avatar = \Images::saveUserGravatar($user);
$user->avatar()->associate($avatar);
$user->save();
}
return $user;
}
示例3: store
/**
* Store a newly created user in storage.
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$this->checkPermission('user-create');
$this->validate($request, ['name' => 'required', 'email' => 'required|email|unique:users,email', 'password' => 'required|min:5', 'password-confirm' => 'required|same:password', 'role' => 'required|exists:roles,id']);
$user = $this->user->fill($request->all());
$user->password = bcrypt($request->get('password'));
$user->save();
$user->attachRoleId($request->get('role'));
// Get avatar from gravatar and save
if (!env('DISABLE_EXTERNAL_SERVICES', false)) {
$avatar = \Images::saveUserGravatar($user);
$user->avatar()->associate($avatar);
$user->save();
}
return redirect('/users');
}
示例4: registerNew
/**
* Creates a new user and attaches a role to them.
* @param array $data
* @return User
*/
public function registerNew(array $data)
{
$user = $this->create($data);
$this->attachDefaultRole($user);
// Get avatar from gravatar and save
if (!config('services.disable_services')) {
try {
$avatar = \Images::saveUserGravatar($user);
$user->avatar()->associate($avatar);
$user->save();
} catch (Exception $e) {
$user->save();
\Log::error('Failed to save user gravatar image');
}
}
return $user;
}