本文整理汇总了PHP中App\Http\Requests\UserRequest::session方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRequest::session方法的具体用法?PHP UserRequest::session怎么用?PHP UserRequest::session使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Requests\UserRequest
的用法示例。
在下文中一共展示了UserRequest::session方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
public function login(UserRequest $request)
{
$credentials = array('name' => $request->get('name'), 'password' => $request->get('password'));
if ($this->auth->attempt($credentials)) {
$request->session()->flash('success', 'You are now logged in!');
}
return redirect('/');
}
示例2: saveUser
public function saveUser(UserRequest $request)
{
DB::beginTransaction();
try {
$this->userRepository->create($request->all());
DB::commit();
$request->session()->flash('message-success', 'Usuário criado com sucesso!');
return redirect()->route('user.create');
} catch (ValidationException $e) {
DB::rollback();
return Redirect::back()->withErrors($e->getErrors())->withInput();
} catch (\Exception $e) {
DB::rollback();
throw $e;
}
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(UserRequest $request)
{
if (isset($_POST['yes'])) {
$user = new User();
//$this->validate($request,['user_name' => 'required','user_pass' => 'required']);
$user->username = $request->input('user_name');
$user->password = $request->input('user_pass');
$userdata = array('username' => $user->username, 'password' => $user->password);
if (Auth::attempt($userdata)) {
$posts = Post::all();
return view('post.index', ['posts' => $posts]);
} else {
$request->session()->flash('alert-danger', 'Please Check username and password');
return redirect('/');
//return view ('login.index');
}
}
}
示例4: changePassword
public function changePassword(UserRequest $request, $token)
{
$input = $request->all();
$yesterday = date('Y-m-d H:i:s', strtotime("24 hours ago"));
// Only select matching tokens from the past day
$user = User::where('reset_token', $token)->where('reset_time', '>=', $yesterday)->first();
if (!$user) {
$request->session()->flash('error', 'Invalid reset code. It may have expired.');
return redirect('/forgot');
}
$user->password = bcrypt($input['password']);
$user->save();
$request->session()->flash('success', 'Your password has been reset, you may now log in.');
return redirect('/login');
}