Add sorting function on table tag

Viewed 137

I'm using Laravel 5.4

So I wanted to know if I'm able to sort things in my table without actually using queries.

Here's my table structure:

<table class="table table-hover">
    <tr>
        <th>ID</th>
        <th>Item</th>
        <th>Total Earnings</th>
        <th>Quantity Sold</th>
        <th>Date</th>
    </tr>
    <thead>
    </thead>
    <tbody>
        @forelse($solditems as $solditem) 
            <tr>
                <td>{{$solditem->item_id}}</td>
                <td>{{$solditem->item}}</td>
                <td>{{$solditem->subtotal}}</td>
                <td>{{$solditem->qty}}</td>
                <td>{{\Carbon\Carbon::parse($solditem->created_at)->format('j F Y h:i A')}}</td>
            </tr>
        @empty
        @endforelse
    </tbody>
</table>
1 Answers
Related