How to catch the Collection sortBy keyword to variable on laravel blade?
Clash Royale CLAN TAG#URR8PPP
How to catch the Collection sortBy keyword to variable on laravel blade?
On blade view .I resort my collection from controller
like below
$search_alls=$search_alls->sortByDesc('id');
or
$search_alls=$search_alls->sortBy('id');
The above is work fine on my blade.
I want to make a dynamic javascript button to change the keywork in the sortby clause,or change sortBy to sobyByDesc.
How can I catch the
->sortBy($keywordvariable)
or catch the
->$sortclausevariable($keywordvariable)?
and how to reload the new sequence $serch_alls? Can by reload page javascript function?
As @AlexvanVliet stated, you cannot modify the PHP code in your blade files. Those are rendered on the server before ever getting to the client (browser). XHR requests are your friend.
– DigitalDrifter
Aug 12 at 7:15
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
You can't run php code from javascript unless you either use AJAX or reload the page.
– Alex van Vliet
Aug 12 at 7:01