redirect()->route('user.show', ['user' => $user_id]);
using with()
will not work with this redirect()->route()
method
Alternatively, without using the redirect helper and using compact
return Redirect::to('users.overview')->with(compact('properties'))
Single parameter:
return view('post.show')->with('post', $post);
Note: This with()
method can be used to pass objects (not arrays) into the view.
An example of this would be the User
or Post
object class, rather than an array of unrelated properties.
Multiple parameters:
return view('profile.show', ['user' => $userid, 'code' => $code_id]);
Route::get('/', function () {
return view('greeting', ['name' => 'Finn']);
});