I try to learn AJAX in this website. Then, I stumbled upon session
in the controller
. The author create the session
like this:
Step 6: Create controller
$request->session()->put('sort', $request->has('sort') ? $request->get('sort') : ($request->session()->has('sort') ? $request->session()->get('sort') : 'asc'));
I try to alter the code to suit my app but it return Order direction must be "asc" or "desc".
This is my code:
$request->session()->put('search', $request->has('search') ? $request->get('search') : ($request->session()->has('search') ? $request->session()->get('search') : ''));
$request->session()->put('field', $request->has('field') ? $request->get('field') : ($request->session()->has('field') ? $request->session()->get('field') : 'user_id'));
$request->session()->put('sort', $request->has('sort') ? $request->get('sort') : ($request->session()->has('sort') ? $request->session()->get('sort') : 'asc'));
When I try to dump the session()->get(sort)
, it always return session[field]
value.
This is my dd()
code:
dd('field: '.$request->session()->get('field').', sort: '.$request->session()->get('sort'));
and it return "field: user_id, sort: user_id"
I'll update my code per ask. TIA.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire