On one page I have a form that is submitted via ajax. I'm trying to save the forms inputs values to the session whenever the filter is ran.
Right now I have this in the controller...
if (count($request->session()->get('filters')) > 0) {
$filters = $request->session()->pull('filters');
var_dump($filters);
foreach ($filters as $filter => $value) {
$request->$filter = $value;
}
$request->session()->put('filters', $request->all());
}
which the var_dump shows that it contains all the selected filters. Then on another page I'm just returning the session, for debugging purposes.
Further down in the controller, for that page I have...
return $request->session()->get('filters');
...and it'll usually return the filters from the first time I search, but then it never updates them. I've tried doing $request->session()->forget('filters'); before putting them back in the session, but it's not updating.
So let's say I search for "foo", the page that returns the filters initially returns this...
{
"page": "1",
"name": "foo"
}
...but then let's say I add another filter called "date" and hit submit... the filter functions and narrows the results, and var dumps this...
array (size=5)
'page' => string '1' (length=1)
'date' => string '2014-01-01' (length=10)
'name' => string 'foo' (length=5)
However, the other page still returns the original results. How can two pages return different results for $request->session()->get('filters')?
All I'm trying to do is save all the filters values to the session, so when a user comes back to the page after browsing a bunch of other pages, the filters are still filled/applied.