I am hacking my way through a Laravel project. I am returning a search-filtered databse query with Laravel and applying a pagination, the pagination works, the query works, but the pagination links go to a blank page, only the first page of results is visible. Any hints would be much appreciated:
Controller:
<?
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;
use App\Job;
use Carbon\Carbon;
class FilterJobsController extends Controller
{
/**
* Show a list of all of the application's users.
*
* @return Response
*/
public function index()
{
$bidded = request('bidded');
$state = request('state');
$city = request('city');
$contractor = request('contractor');
$job = request('job');
$subjob = request('subjob');
$jobs = DB::table('jobs')->where([
['bidded', '=', $bidded],
['state', '=', $state],
['city', '=', $city],
['contractor', '=', $contractor],
['job', '=', $job],
['subjob', '=', $subjob],
])->paginate(3);
return view('jobs.index', compact('jobs')->with('links', $links));
}
}
The blade file:
@extends ('layouts.master')
@section ('content')
<div class="jobs">
@foreach(array_chunk($jobs->getCollection()->all(), 3) as $page)
<div class="leftarrow">❰</div>
@foreach ($jobs as $job)
@include ('jobs.job')
@endforeach
<div class="pagenumbers">
{{ $jobs->links() }} <<<<This is the invalid pagination location
</div> <div class="rightarrow"> <!-- <a href="{{ url('/jobs/') }}"> -->
❱
<!-- </a> --> </div> <div class="downarrowrow"> <div class="downarrow">❱❱</div> </div>
@endforeach
</div>
@endsection
Tthe first page return works in this example with 3 records, it is the rest of the pagination links, eg "page2" that simply links to a blank page.