i am trying to redirect using a function in my main controller with both variables and a message.
The message code is fine and is usually displayed by ->with('abo', 'messagetext').
The Problem is that not both types are redirected, only the variables (without the message) :(
public function subscribe(Request $request)
{
$suchString = $request->input('suchString');
$userId = $request->input('userId');
Subscribe::create([
'abo_string' => $suchString,
'userid' => $userId
]);
$suche = Document::where( 'title', 'LIKE', '%' . $suchString . '%' )
->orWhere( 'category', 'LIKE', '%' . $suchString . '%' )
->orWhere( 'description', 'LIKE', '%' . $suchString . '%' )
->get();
$users = User::all();
return view('pages.search')->with('abo', 'messagetext');
}
You should try the compact()
method to redirect your variable.
session()->flash( 'abo', 'Your message' );
return view('pages.search', compact('suchString', 'userId', 'suche' ));