本文整理汇总了PHP中Illuminate\Http\Request::flash方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::flash方法的具体用法?PHP Request::flash怎么用?PHP Request::flash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Http\Request
的用法示例。
在下文中一共展示了Request::flash方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticated
/**
* Overrides the action when a user is authenticated.
* If the user authenticated but does not exist in the user table we create them.
* @param Request $request
* @param Authenticatable $user
* @return \Illuminate\Http\RedirectResponse
* @throws AuthException
*/
protected function authenticated(Request $request, Authenticatable $user)
{
// Explicitly log them out for now if they do no exist.
if (!$user->exists) {
auth()->logout($user);
}
if (!$user->exists && $user->email === null && !$request->has('email')) {
$request->flash();
session()->flash('request-email', true);
return redirect('/login');
}
if (!$user->exists && $user->email === null && $request->has('email')) {
$user->email = $request->get('email');
}
if (!$user->exists) {
// Check for users with same email already
$alreadyUser = $user->newQuery()->where('email', '=', $user->email)->count() > 0;
if ($alreadyUser) {
throw new AuthException('A user with the email ' . $user->email . ' already exists but with different credentials.');
}
$user->save();
$this->userRepo->attachDefaultRole($user);
auth()->login($user);
}
$path = session()->pull('url.intended', '/');
$path = baseUrl($path, true);
return redirect($path);
}
示例2: update
public function update(Request $request, $id = 0)
{
if ($id) {
try {
$role = Role::findOrFail($id);
} catch (ModelNotFoundException $e) {
$request->flash();
return redirect('admin/role', ['errors' => $e]);
}
} else {
return redirect('admin/role', ['errors' => 'ID is missing. ']);
}
$data = ['name' => $request->input('name'), 'slug' => $request->input('slug'), 'description' => $request->input('description'), 'level' => $request->input('level')];
$validator = Validator::make($data, ['name' => 'required', 'slug' => "required|unique:roles,slug,{$id}|alpha", 'level' => 'required|integer']);
if ($validator->fails()) {
$request->flash();
return view('admin.role.show', ['act' => $id, 'role' => [], 'errors' => $validator->messages()]);
} else {
$role->name = $data['name'];
$role->slug = $data['slug'];
$role->description = $data['description'];
$role->level = $data['level'];
$role->save();
return redirect('admin/role');
}
}
示例3: index
public function index(Request $request)
{
$request->flash();
$items = Item::search($request);
// dd($request);
return view('spareparts.index', compact('items'));
}
示例4: postPost
public function postPost(Request $request)
{
$input = $request->all();
$rules = ['title' => ['max:20', 'required'], 'content' => ['min:10', 'required']];
$validator = Validator::make($input, $rules);
$returnInf = [];
if ($validator->fails()) {
$messages = $validator->messages();
foreach ($array_dot($messages->toArray) as $value) {
array_push($returnInf, $value);
}
Session::flash('operationResult', 'am-alert-warning');
Session::flash('returnInf', $returnInf);
return redirect()->back()->withInput(Request::flash());
} else {
$article = Article::create(['title' => $input['title'], 'content' => Common::encodeTopicContent($input['content']), 'node_id' => $input['node_id'], 'user_id' => $input['user_id']]);
if ($article->id > 0) {
array_push($returnInf, '发帖成功');
Session::flash('operationResult', 'am-alert-success');
Node::find($input['node_id'])->increment('article_count');
User::find($input['user_id'])->increment('article_count');
} else {
array_push($returnInf, '我们的数据库出问题啦,请稍后再试=。=');
Session::flash('operationResult', 'am-alert-warning');
}
}
Session::flash('returnInf', $returnInf);
return redirect()->back();
}
示例5: postLogin
public function postLogin(Request $request)
{
if (Auth::attempt(['name' => Input::get('name'), 'password' => Input::get('password')])) {
return Redirect::to('index');
} else {
return Redirect::to('login')->with('data', 'Login Failed')->withInput($request->flash());
}
}
示例6: validate
/**
* Validate the given request with the given rules.
*
* @param \Illuminate\Http\Request $request
* @param array $rules
* @param array $messages
* @param array $customAttributes
* @return void
* @throws HttpException
*/
public function validate(Request $request, array $rules, array $messages = [], array $customAttributes = [])
{
/** @var \Illuminate\Validation\Validator $validator */
$validator = Validator::make($request->all(), $rules, $messages, $customAttributes);
if ($validator->fails()) {
$request->flash();
throw new HttpException(Response::HTTP_NOT_ACCEPTABLE, $validator->errors()->first());
}
}
示例7: postLogin
public function postLogin(Request $request)
{
if (Auth::attempt(['email' => $request['email'], 'password' => $request['password'], 'active' => 1])) {
return redirect('admin/home');
} else {
$request->flash();
return redirect('/admin/login')->withInput($request->only('email', 'remember'))->withErrors(['email' => 'These credentials do not match our records.']);
}
}
示例8: validate
/**
* Validate the given request with the given rules.
*
* @param \Illuminate\Http\Request $request
* @param array $rules
* @param array $messages
* @param array $customAttributes
* @return void
* @throws HttpXpressengineException
*/
public function validate(Request $request, array $rules, array $messages = [], array $customAttributes = [])
{
$validator = Validator::make($request->all(), $rules, $messages, $customAttributes);
if ($validator->fails()) {
$request->flash();
$e = new HttpXpressengineException(Response::HTTP_NOT_ACCEPTABLE);
$e->setMessage($validator->errors()->first());
throw $e;
}
}
示例9: lists
/**
* @param Guard $auth
* @param Request $request
* @param string $rp_id
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function lists(Guard $auth, Request $request, $rp_id)
{
$data = $this->data($auth->user());
$headers = [];
if ($request->has('_token')) {
$request->flash();
}
$headers = $this->repository->getHeaderList($request);
return view('td.pre-approved.list', compact('rp_id', 'headers', 'data'));
}
示例10: login
public function login(Request $request)
{
$email = $request->get('email');
$password = $request->get('password');
if (\Auth::attempt(['email' => $email, 'password' => $password])) {
return redirect(route('home'));
} else {
$request->flash();
return view('auth/login');
}
}
示例11: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
$request->flash();
$users = User::search($request);
// $roles = Role::where('id', '>', 2)->first();
// if(!empty($roles)){
// $users = $roles->users()->get();
// }
$roles = Role::orderBy('name')->lists('name', 'id');
return view('store_user.index', compact('users', 'roles'));
}
示例12: login
protected function login(Request $request)
{
// we flash the request
$request->flash();
// we sanitize the entries
$request->replace(InputSanitizer::sanitize($request->all()));
// we set the remember to false if we do not find it
$request->merge(['remember' => $request->get('remember', false)]);
// we check the inputs validity
$rules = ['email' => 'required|email', 'password' => 'required', 'remember' => 'required|boolean'];
if (!Validation::check($request->all(), $rules)) {
return redirect()->back();
}
// we try to authenticate the user
try {
if (!($user = Sentinel::authenticate($request->except('remember'), $request->get('remember')))) {
Modal::alert([trans('auth.message.login.failure')], 'error');
return redirect()->back();
}
// we notify the current user
Modal::alert([trans('auth.message.login.success', ['name' => $user->first_name . " " . $user->last_name])], 'success');
// redirect to the url stored in the session
if ($url = session()->get('previous_url')) {
session()->forget('previous_url');
return redirect($url);
} else {
// or redirect to home
return redirect(route('home'));
}
} catch (NotActivatedException $e) {
// we log the error
CustomLog::error($e);
// we notify the current user
Modal::alert([trans('auth.message.activation.failure'), trans('auth.message.activation.email.resend', ['email' => $request->get('email'), 'url' => route('account.activation_email', ['email' => $request->get('email')])])], 'error');
return redirect()->back();
} catch (ThrottlingException $e) {
switch ($e->getType()) {
case 'ip':
// we notify the current user
Modal::alert([trans('auth.message.throttle.ip', ['seconds' => $e->getDelay()])], 'error');
break;
default:
// we notify the current user
Modal::alert([$e->getMessage()], 'error');
break;
}
return redirect()->back();
} catch (Exception $e) {
// we notify the current user
\Modal::alert([trans('auth.message.login.error'), trans('global.message.global.failure.contact.support', ['email' => config('settings.support_email')])], 'error');
return redirect()->back();
}
}
示例13: showGamesForm
/**
* Shows Form to save games in database.
*
* @vereine array
*/
public function showGamesForm(Request $request)
{
$matchday = $request->input('matchday');
$league = $request->input('league');
$season = $request->input('season');
$getLeague = DB::table('leagues')->select('league')->get();
$getSeason = DB::table('matches')->select('season')->groupBy('season')->get();
$getMatchdayCount = Matches::select('matchday')->groupBy('matchday')->get();
$request->flash();
$matches = Matches::where('matchday', $matchday)->where('leagues.league', $league)->where('matches.season', $season)->join('clubs as homeclub', 'matches.home_id', '=', 'homeclub.id')->join('clubs as awayclub', 'matches.away_id', '=', 'awayclub.id')->join('leagues', 'matches.league_id', '=', 'leagues.id')->select('matches.*', 'homeclub.club as home', 'awayclub.club as away', 'leagues.league')->orderBy('date')->get();
return view('admin.savematches', compact('matches', 'getMatchdayCount', 'getLeague', 'getSeason', 'league', 'season'));
}
示例14: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
// get category in select field for filtering
$category = $request->get('category');
// filter by catergoy
if ($category && $category != 'All') {
$threads = Thread::where('category', $category)->orderBy('created_at', 'desc')->get();
} else {
$threads = Thread::orderBy('created_at', 'desc')->get();
}
// Flash old input to repopulate on search
$request->flash();
return view('threads.index', ['threads' => $threads]);
}
示例15: delete
public function delete(Request $request, $id = 0)
{
if ($id) {
try {
$user = User::findOrFail($id);
} catch (ModelNotFoundException $e) {
$request->flash();
return redirect('admin/user', ['act' => $id, 'errors' => $e]);
}
} else {
return redirect('admin/user');
}
$user->delete();
return redirect('admin/user');
}