How am I able to return view(‘support’) with following:
->withInput()
->with('success', 'Found results');
Code
// if validation do not fail
if ($validated->fails() === false) {
//session()->flashInput($request->input());
// return
return view('siteadmin.support.support', [
'articles' => $articles,
'categories' => $categories,
]);
}
Following code is not working:
Code
// if validation do not fail
if ($validated->fails() === false) {
//session()->flashInput($request->input());
// return
return view('siteadmin.support.support', [
'articles' => $articles,
'categories' => $categories,
])
->withInput()
->with('success', 'Found results');
}
3
Answers
So you can do this in multiple ways. Through sessions or through the view. Firstly if you have session messages setup you can throw a message like this
Or you can pass the success message through the view like
You may use the
withInput
method provided by theRedirectResponse
instance to flash the current request’s input data to the session before redirecting the user to a new location. This is typically done if the user has encountered a validation error. Once the input has been flashed to the session, you may easily retrieve it during the next request to repopulate the form:return back()->withInput();
Store it in a
session
you can usesession()
helper or$request->session->put()
then you can just access the session value in blade using the
session()
helper.