Reputation: 1796
I am redirecting a page like this:
return redirect('vendor/vendors')->with('vendor', $allvendors);
and getting it from Blade template like this:
@foreach($vendor as $vendors)
but it's not working or at times when it loads, and I refresh the page, it will give error like the data has been deleted:
Undefined variable: vendor (View: /opt/lampp/htdocs/easyhire-web/resources/views/vendor/vendors.blade.php)
Upvotes: 0
Views: 491
Reputation: 6976
The with
method on the redirect response is meant for passing flashed session data. That data does not persist, so if you code your view to expect that data to be present on every request it will fail on normal page loads.
Any data that you need should be retrieved in the controller action that corresponds to the URL you are redirecting to.
Upvotes: 3