本文整理汇总了PHP中Self::saveImage方法的典型用法代码示例。如果您正苦于以下问题:PHP Self::saveImage方法的具体用法?PHP Self::saveImage怎么用?PHP Self::saveImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Self
的用法示例。
在下文中一共展示了Self::saveImage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$validator = \Validator::make(\Input::all(), array('name' => 'required', 'surname' => 'required', 'email' => 'required|email|unique:users', 'password' => 'required|confirmed|min:6', 'permission_group_id' => 'required|integer', 'dob' => 'date', 'language' => 'required'));
if ($validator->fails()) {
return \Redirect::back()->withInput()->withErrors($validator);
}
$user = User::create(array('name' => \Input::get('name'), 'surname' => \Input::get('surname'), 'email' => \Input::get('email'), 'permission_group_id' => \Input::get('permission_group_id'), 'password' => \Hash::make(\Input::get('password')), 'dob' => \Input::get('dob'), 'language' => \Input::get('language')));
//upload of user image
if (\Input::has('img_url')) {
Self::saveImage(\Input::get('img_url'), $user, true);
}
return \Redirect::route('user.index');
}
示例2: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$user = User::findOrFail($id);
$validator = \Validator::make(\Input::all(), array('name' => 'required', 'surname' => 'required', 'password' => 'confirmed|min:6', 'permission_group_id' => 'required|integer', 'dob' => 'date', 'language' => 'required'));
if ($validator->fails()) {
return \Redirect::back()->withInput()->withErrors($validator);
}
$user->name = \Input::get('name');
$user->surname = \Input::get('surname');
$user->permission_group_id = \Input::get('permission_group_id');
$user->dob = \Input::get('dob');
$user->language = \Input::get('language');
if (strlen(\Input::get('password'))) {
$user->password = \Hash::make(\Input::get('password'));
}
//upload of user image
if (\Input::has('img_url')) {
Self::saveImage(\Input::get('img_url'), $user, false);
}
$user->save();
$messages = with(new MessageBag())->add('success', 'Usuário modificado com sucesso!');
return \Redirect::route('user.index')->with('messages', $messages);
}