mirror of
https://koodu.h-i.works/projects/thebadspace
synced 2025-06-25 16:04:37 -05:00
Built out Listing Page, font update
Plugged in the layout for the Listings page and turned on pagination. Also updated the font to rubrik. Because it's pretty.
This commit is contained in:
@ -7,6 +7,8 @@ use App\Models\Location;
|
||||
|
||||
class FrontIndexController extends Controller
|
||||
{
|
||||
private $limit = 15;
|
||||
|
||||
public function start()
|
||||
{
|
||||
$locations = Location::where("active", true)->get();
|
||||
@ -21,4 +23,33 @@ class FrontIndexController extends Controller
|
||||
'title' => "The Bad Space"
|
||||
]);
|
||||
}
|
||||
|
||||
public function listings(int $pageNum = 1)
|
||||
{
|
||||
$range = $pageNum * $this->limit - $this->limit;
|
||||
$active = Location::where("active", true)->get();
|
||||
$locations = Location::where("active", true)
|
||||
->limit($this->limit)->offset($range)->orderByDesc('id')->get();
|
||||
$pageCount = ceil(count($active) / $this->limit);
|
||||
|
||||
$next = $pageNum + 1;
|
||||
if ($next > $pageCount) {
|
||||
$next = 1;
|
||||
}
|
||||
|
||||
$prev = $pageNum - 1;
|
||||
|
||||
if ($prev <= 0) {
|
||||
$prev = $pageCount;
|
||||
}
|
||||
|
||||
return view('front.listing', [
|
||||
'title' => "Listings",
|
||||
"totalPages" => $pageCount,
|
||||
"prev" => $prev,
|
||||
"next" => $next,
|
||||
'pageNum' => $pageNum,
|
||||
'locations' => $locations
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user