Reputation: 2781
After saving user, I want to return to the same tab in the page with success message. How do I add hashtag in the view path or route path in laravel
if($user->save()){
$success = "User Registered";
return View::make('user')->with('success', $success);
When I try this, it gives me an error :-
return View::make('user#adduser')->with('success', $success);
View [user#adduser] not found
Thanks
Upvotes: 1
Views: 2269
Reputation: 19285
You can generate the url that will render the view with route('user')
and append a hash at the end of it.
So, the redirect could be:
return Redirect::to( route('user') . '#adduser')->with('success', $success);
Of course you'll need a proper set up to show the view from the route returned by route('user')
: a routes.php
entry and controller method to to show the view
Something like this:
routes.php
Route::get('user', 'UserController@show');
UserController.php
public function show()
{
return View::make('user');
}
Upvotes: 1
Reputation: 5876
I am not sure that is possible, you can use a redirect to go to the page with hash and the success message:
return Redirect::to('user#adduser')->with('success', $success);
Upvotes: 0