title: Pagination is not showing
body: <p>I'm trying to get pagination into my view. I don't know where is the problem, the code doesn't show any errors.</p>
  
  <p><strong>Here is my controller function</strong> </p>
  
  <pre><code>public function apakskategorijas($id)
      {
          $apakskat = apakskategorijas::with('prece')-&gt;where('id',$id)-&gt;paginate(2);      
          return view ('kategorijas.apakskategorijas',compact('apakskat'));
      }
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>@section('content')
  
      @foreach($apakskat as $apk)
      @foreach($apk-&gt;prece as $prec)
  
      &lt;div class="col-md-4 kat"&gt;
          &lt;a href="{{ url('kategorija/apakskategorija/preces/'.$prec-&gt;id) }}"&gt;
              &lt;div&gt;
                  &lt;img src="{{ URL::to($prec-&gt;path) }}"&gt; 
              &lt;/div&gt;
              &lt;div class="nos"&gt;
                  &lt;p&gt;{{$prec-&gt;nosaukums}}&lt;/p&gt;
              &lt;/div&gt;&lt;/a&gt;    
              &lt;div class="price-box-new discount"&gt;
                  &lt;div class="label"&gt;Cena&lt;/div&gt;
                  &lt;div class="price"&gt;{{ $prec-&gt;cena }} €&lt;/div&gt;                
              &lt;/div&gt;
              &lt;div&gt;&lt;a href="" class="button btn-cart "&gt;&lt;span&gt;Ielikt grozā&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;      
      &lt;/div&gt;
  
      @endforeach
      @endforeach
  
      &lt;center&gt;{{$apakskat-&gt;links()}}&lt;/center&gt; &lt;--pagination
      @endsection
  </code></pre>
  
  <p><strong>dd($apakskat)</strong></p>
  
  <p><a href="https://i.stack.imgur.com/ZJ1kQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZJ1kQ.png" alt="enter image description here"></a></p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>when i changed code in my controller to <code>$apakskat = apakskategorijas::paginate(1);</code> then it showed me pagination, but this doesn't work for me since i need to display items in each subcategory, with this code it just displays every item i have,it doesn't filter which subcategory is selected.</p>
  
  <p>This is why i need this <code>$apakskat = apakskategorijas::with('prece')-&gt;where('id',$id)-&gt;paginate(1);</code> with is a function that i call which creates a relation between tables, so that it would display every item with its related subcategory.</p>