mirror of
https://koodu.h-i.works/projects/thebadspace
synced 2025-06-25 16:04:37 -05:00
Added Pagination Service class
Pagination is going to need some additional features in the near future, so it made sense to give it it's own seperate class.
This commit is contained in:
@ -5,18 +5,22 @@ namespace App\Http\Controllers;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Repositories\LocationRepository;
|
||||
use App\Repositories\SourceRepository;
|
||||
use App\Services\PaginationService;
|
||||
|
||||
class FrontIndexController extends Controller
|
||||
{
|
||||
protected $location;
|
||||
protected $source;
|
||||
protected $pagination;
|
||||
|
||||
public function __construct(
|
||||
LocationRepository $locationRepository,
|
||||
SourceRepository $sourceRepository
|
||||
SourceRepository $sourceRepository,
|
||||
PaginationService $paginationService
|
||||
) {
|
||||
$this->location = $locationRepository;
|
||||
$this->source = $sourceRepository;
|
||||
$this->location = $locationRepository;
|
||||
$this->source = $sourceRepository;
|
||||
$this->pagination = $paginationService;
|
||||
}
|
||||
|
||||
public function start()
|
||||
@ -79,16 +83,16 @@ class FrontIndexController extends Controller
|
||||
|
||||
public function listings(int $pageNum = 1)
|
||||
{
|
||||
$listing = $this->location->getPage($pageNum);
|
||||
$page = $this->pagination->getPage($pageNum);
|
||||
|
||||
return view('front.listing', [
|
||||
'title' => "Listings",
|
||||
'sources' => count($this->source->getActive()),
|
||||
"totalPages" => $listing[1],
|
||||
"prev" => $listing[2],
|
||||
"next" => $listing[3],
|
||||
"totalPages" => $page['pageCount'],
|
||||
"prev" => $page['prev'],
|
||||
"next" => $page['next'],
|
||||
'pageNum' => $pageNum,
|
||||
'locations' => $listing[0]
|
||||
'locations' => $page['locations']
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user