title: Laravel pagination table - sort for one column
body: <p>I currently have the following:</p>
  
  <pre><code>&lt;table class="table table-striped"&gt;
      &lt;tr&gt;
          &lt;th&gt; Artikelbild &lt;/th&gt;
          &lt;th&gt; Artikelnummer &lt;/th&gt;
          &lt;th&gt; Name des Artikels &lt;/th&gt;
          &lt;th&gt; Beschreibung &lt;/th&gt;
          &lt;th&gt; Preis &lt;/th&gt;
          &lt;th&gt; Kategorie &lt;/th&gt;
      &lt;/tr&gt; @foreach($products as $product)
      &lt;tr class='clickable-row' &lt;?php if($product-&gt;stockCount === 0) echo "style='color:red;'";?&gt;data-href="{{url('/product')}}
          &lt;?php echo '/'.$product-&gt;id;?&gt;"&gt;
          &lt;td&gt; &lt;img src="/images/{{$product-&gt;imageUrl}}" class="productImageSmall" /&gt; &lt;/td&gt;
          &lt;td&gt; {{$product-&gt;id}} &lt;/td&gt;
          &lt;td&gt; {{$product-&gt;name}} &lt;/td&gt;
          &lt;td&gt;
              &lt;?php if (strlen($product-&gt;description) &gt; 30) { $productShortened = substr($product-&gt;description, 0, 30) . "[...]"; } else { $productShortened = $product-&gt;description; } echo $productShortened; ?&gt; &lt;/td&gt;
          &lt;td&gt;
              &lt;?php echo number_format($product-&gt;price, 2, ',', '.');?&gt;€ &lt;/td&gt;
          &lt;td&gt; {{$product-&gt;categoryName}} &lt;/td&gt;
      &lt;/tr&gt; @endforeach
  &lt;/table&gt;
  </code></pre>
  
  <p>The <code>$product</code> thing is passed from my controller with the <code>paginate()</code> option.</p>
  
  <p>Now I want that this table is sort-able by one column. So lets say, the user clicks on the "price" (or Preis in german) column on top of the table, then all results should be sorted by the price (from low to high or from high to low), same for the category, for the name and every other column.</p>
  
  <p>How can I do this? Do I have to reload the page and get the data again from the db, but somehow sorted (if yes, how?). Or can I somehow just sort it without reloading it? How can I do this?</p>
  
  <p>Thanks for any help</p>