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) {