From 958f54b9bd0ba5fca0b5113d6dd21f126a7d5cec Mon Sep 17 00:00:00 2001 From: Kekskurse Date: Mon, 8 Feb 2021 01:38:51 +0100 Subject: [PATCH] Stuff --- app/Http/Controllers/PublicController.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/PublicController.php b/app/Http/Controllers/PublicController.php index f0b7bf8..dc27b02 100644 --- a/app/Http/Controllers/PublicController.php +++ b/app/Http/Controllers/PublicController.php @@ -42,12 +42,23 @@ class PublicController extends BaseController $page = $request->input("page", 1); $r = $g->forPage($page, 10); + $next = null; + $preview = null; + + if($page > 1) { + $preview = url("/".$tenant->url.".json?page=".($page-1)); + } + + if($page >= ($g->count() / 10)) { + $next = url("/".$tenant->url.".json?page=".($page+1))]; + } + return response()->json(["pagination" => [ "total" => $g->count(), "items_per_page" => 10, "pages" => ($g->count() / 10), - "preview" => url("/".$tenant->url.".json?page=".($page-1)), - "next" => url("/".$tenant->url.".json?page=".($page+1))], + "preview" => $preview, + "next" => $next, "data" => \App\Http\Resources\Gallery::collection($r)]); } public function listGalleriesView($name, Request $request) {