From fb10aec4dd8106b85835a1b785dfb1a7f8a42070 Mon Sep 17 00:00:00 2001 From: alaaelgndy Date: Sat, 22 Aug 2020 15:35:05 +0200 Subject: [PATCH] Configure the pagination to each resource --- config/wink.php | 15 +++++++++++++++ src/Http/Controllers/PagesController.php | 2 +- src/Http/Controllers/PostsController.php | 2 +- src/Http/Controllers/TagsController.php | 2 +- src/Http/Controllers/TeamController.php | 2 +- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/config/wink.php b/config/wink.php index 7485d9d1..b75fbd6b 100644 --- a/config/wink.php +++ b/config/wink.php @@ -94,4 +94,19 @@ 'default' => null, ], + + /* + |-------------------------------------------------------------------------- + | The pagination of wink collections + |-------------------------------------------------------------------------- + | + | You can configure here the number of items, per page. + | + */ + 'pagination' => [ + 'posts' => 30, + 'tags' => 30, + 'teams' => 30, + 'pages' => 30, + ], ]; diff --git a/src/Http/Controllers/PagesController.php b/src/Http/Controllers/PagesController.php index fb6a1e9d..2712ab13 100644 --- a/src/Http/Controllers/PagesController.php +++ b/src/Http/Controllers/PagesController.php @@ -20,7 +20,7 @@ public function index() $q->where('title', 'LIKE', '%'.request('search').'%'); }) ->orderBy('created_at', 'DESC') - ->paginate(30); + ->paginate(config('wink.pagination.pages', 30)); return PagesResource::collection($entries); } diff --git a/src/Http/Controllers/PostsController.php b/src/Http/Controllers/PostsController.php index 3817e070..e40742a5 100644 --- a/src/Http/Controllers/PostsController.php +++ b/src/Http/Controllers/PostsController.php @@ -30,7 +30,7 @@ public function index() }) ->orderBy('created_at', 'DESC') ->with('tags') - ->paginate(30); + ->paginate(config('wink.pagination.posts', 30)); return PostsResource::collection($entries); } diff --git a/src/Http/Controllers/TagsController.php b/src/Http/Controllers/TagsController.php index 36523173..ddc394fc 100644 --- a/src/Http/Controllers/TagsController.php +++ b/src/Http/Controllers/TagsController.php @@ -21,7 +21,7 @@ public function index() }) ->orderBy('created_at', 'DESC') ->withCount('posts') - ->paginate(30); + ->paginate(config('wink.pagination.tags', 30)); return TagsResource::collection($entries); } diff --git a/src/Http/Controllers/TeamController.php b/src/Http/Controllers/TeamController.php index 3e302c70..f4a2f738 100644 --- a/src/Http/Controllers/TeamController.php +++ b/src/Http/Controllers/TeamController.php @@ -22,7 +22,7 @@ public function index() }) ->orderBy('created_at', 'DESC') ->withCount('posts') - ->paginate(30); + ->paginate(config('wink.pagination.teams', 30)); return TeamResource::collection($entries); }