Skip to content

Commit

Permalink
Merge pull request #279 from NizarBerjawi/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
NizarBerjawi authored Dec 10, 2021
2 parents 75fc373 + dd372db commit e4c7c62
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 74 deletions.
46 changes: 4 additions & 42 deletions app/Http/Controllers/Api/V1/spec/response.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @OA\Property(
* property="links",
* type="object",
* description="Determines if the alternate name is official/preferred.",
* description="Display the links to other pages of the response",
* @OA\Property(
* property="first",
* type="string",
Expand All @@ -37,7 +37,7 @@
* property="last",
* type="string",
* example=LAST,
* description="The last page in the paginated data set."
* description="The last page in the paginated data set. For performance reasons, this is always null"
* ),
* @OA\Property(
* property="prev",
Expand All @@ -55,7 +55,7 @@
* @OA\Property(
* property="meta",
* type="object",
* description="Determines if the alternate name is official/preferred.",
* description="Meta data related to paginated responses",
* @OA\Property(
* property="currentPage",
* type="integer",
Expand All @@ -69,38 +69,6 @@
* description="The index of the first item on the current page relative to all the data set."
* ),
* @OA\Property(
* property="lastPage",
* type="integer",
* example="21",
* description="The last possible page in this data set."
* ),
* @OA\Property(
* property="links",
* type="array",
* description="",
* @OA\Items(
* @OA\Property(
* property="url",
* type="string",
* example=PAGE_URL,
* description="The url to this pagination item."
* ),
* @OA\Property(
* property="label",
* type="string",
* example="10",
* description="The pagination label."
* ),
* @OA\Property(
* property="active",
* type="boolean",
* example="true",
* description="Determines whether the current URL is active or not."
* ),
* )
*
* ),
* @OA\Property(
* property="path",
* type="string",
* example=PAGE_PATH,
Expand All @@ -117,13 +85,7 @@
* type="integer",
* example="30",
* description="The index of the last item on the current page relative to all the data set."
* ),
* @OA\Property(
* property="total",
* type="integer",
* example="680",
* description="The count of all the items in the data set regardless of pagination."
* ),
* )
* )
* )
* }
Expand Down
6 changes: 3 additions & 3 deletions app/Queries/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Queries;

use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\AbstractPaginator;
use Spatie\QueryBuilder\QueryBuilder;

abstract class Query
Expand Down Expand Up @@ -131,9 +131,9 @@ public function getBuilder(): QueryBuilder
* )
* )
*
* @return \Illuminate\Pagination\LengthAwarePaginator
* @return \Illuminate\Pagination\AbstractPaginator
*/
public function getPaginator(): LengthAwarePaginator
public function getPaginator(): AbstractPaginator
{
$this->checkBuilder();

Expand Down
2 changes: 1 addition & 1 deletion config/json-api-paginate.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* If you only need to display Next and Previous links, you may use
* simple pagination to perform a more efficient query.
*/
'use_simple_pagination' => false,
'use_simple_pagination' => true,

/*
* Here you can override the base url to be used in the link items.
Expand Down
2 changes: 1 addition & 1 deletion resources/views/additionalResources/continents.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</table>
</div>

{{ $continents->onEachSide(1)->links('partials.pagination') }}
{{ $continents->links('partials.pagination') }}
</article>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/additionalResources/countries.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</table>
</div>

{{ $countries->onEachSide(1)->links('partials.pagination') }}
{{ $countries->links('partials.pagination') }}
</article>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/additionalResources/featureCodes.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</table>
</div>

{{ $featureCodes->onEachSide(1)->links('partials.pagination') }}
{{ $featureCodes->links('partials.pagination') }}
</article>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/additionalResources/languages.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</table>
</div>

{{ $languages->onEachSide(1)->links('partials.pagination') }}
{{ $languages->links('partials.pagination') }}
</article>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/additionalResources/timeZones.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</table>
</div>

{{ $timeZones->onEachSide(1)->links('partials.pagination') }}
{{ $timeZones->links('partials.pagination') }}
</article>
</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion resources/views/intro.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,12 @@
<pre>GET /api/v1/featureCodes?page[number]=3</pre>
<p>The above request will return all the results on the 3rd page.</p>

<p> You can control the number of items per page using the <code>page[size]</code> query parameter.
<p>You can control the number of items per page using the <code>page[size]</code> query parameter.
</p>
<pre>GET /api/v1/featureCodes?page[number]=3&page[size]=5</pre>

<p>To improve the performance of the API, some pagination meta data is not computed</p>

<h1>Rate-Limiting</h1>
<p>At this point in time, users can make a <code>100</code> requests per minute to the API before
getting
Expand Down
43 changes: 21 additions & 22 deletions resources/views/partials/pagination.blade.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
@if ($paginator->hasPages())
<nav class="pagination is-centered" role="navigation" aria-label="pagination">
<nav class="pagination is-centered" role="navigation" aria-label="pagination">
<ul class="pagination-list m-0">
{{-- Pagination Elements --}}
@foreach ($elements as $element)
{{-- "Three Dots" Separator --}}
@if (is_string($element))
<li>
<span class="pagination-ellipsis">{{ $element }}</span>
</li>
@endif
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<li class="pagination-previous is-disabled" aria-disabled="true">
<span>@lang('Prev')</span>
</li>
@else
<li class="pagination-previous">
<a href="{{ $paginator->previousPageUrl() }}" rel="prev">@lang('Prev')</a>
</li>
@endif

{{-- Array Of Links --}}
@if (is_array($element))
@foreach ($element as $page => $url)
@if ($page == $paginator->currentPage())
<li class="pagination-link is-current" aria-current="page"><span>{{ $page }}</span></li>
@else
<li>
<a href="{{ $url }}" class="pagination-link">{{ $page }}</a>
</li>
@endif
@endforeach
@endif
@endforeach
{{-- Next Page Link --}}
@if ($paginator->hasMorePages())
<li class="pagination-next">
<a href="{{ $paginator->nextPageUrl() }}" rel="next">@lang('Next')</a>
</li>
@else
<li class="pagination-next is-disabled" aria-disabled="true">
<span>@lang('Next')</span>
</li>
@endif
</ul>
</nav>
@endif

0 comments on commit e4c7c62

Please sign in to comment.