Laravel9 sorting functionality has been introduced by Kyslik/column-sortable.
I am using "New Listings" and "ABC" sorting. I would like to sort only "New Listings" by desc.
Currently, when you click on "New Listings", the URL is sort=created_at&direction=asc. I would like to change this to sort=created_at&direction=desc, but I don't know how.
How can I use Kyslik/column-sortable to make some sorting default to desc?
Controller
public function company_list()
{
$company_total = User::all();
$users=User::sortable()->orderBy('created_at','desc')->paginate(5);
return view('/company-list',compact('users','company_total'));
}
view
<p class="companies-content__order-by-link link-asc">@sortablelink('created_at', 'New Listings')</p>
<p class="companies-content__order-by-link link-asc">@sortablelink('company_name_abc', 'ABC')</p>