Skip to content

Commit

Permalink
Adición componente de paginación de registros en módulo Productos
Browse files Browse the repository at this point in the history
  • Loading branch information
FazeElian committed Feb 28, 2024
1 parent bd96fba commit 7130881
Show file tree
Hide file tree
Showing 15 changed files with 570 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function index(Request $request)
->where("name", "LIKE", "%" . $inputSearchValue . "%")
->orWhere("categorie_id", "LIKE", "%" . $inputSearchValue . "%")
->orderBy("name", "asc")
->paginate(10);
->paginate(8); // Paginación de registros

$categories = Category::select("id", "name")->get();

Expand Down
89 changes: 89 additions & 0 deletions public/assets/css/Admin/paginacion-registros.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/* Contenedor paginación de registros */
.cont-pagination{
display: flex;
width: 100%;
height: 35px;
}

/* Paginación */
.paginate{
display: flex;
width: auto;
height: 100%;
margin: 0;
}

/* Botones paginación */
.btn-pag{
display: flex;
width: 40px;
height: 100%;
font-size: 15px;
margin-right: 1px;
background: transparent;
border: none;
cursor: pointer;
align-items: center;
justify-content: center;
background-color: #D9D9D9;
border: 1px solid black;
}

.btn-pag a{
display: flex;
align-items: center;
justify-content: center;
}

.btn-pag img{
display: flex;
width: 15px;
height: 15px;
}

/* Botones paginación con imagen */
.btn-img{
background-color: #212EC2;
color: white;
}

/* Responsive 1440px */
@media (max-width: 1440px){
.cont-pagination{
height: 30px;
}

.btn-pag{
width: 35px;
font-size: 13px;
}

.btn-pag img{
display: flex;
width: 12px;
height: 12px;
}
}

/* Responsive 425px */
@media (max-width: 425px){
.cont-pagination{
margin: 1rem 0 0;
}

.btn-pag{
font-size: 11px;
}

.btn-pag img{
width: 12px;
height: 12px;
}
}

/* Responsive 320px */
@media (max-width: 320px){
.cont-pagination{
justify-content: center;
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions resources/views/Admin/pagination.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<head>
{{-- Estilos para este componente --}}
<link rel="stylesheet" href="{{ asset("assets/css/Admin/paginacion-registros.css") }}">
</head>

@if ($paginator->hasPages())
<div class="cont-pagination">
<ul class="paginate">
{{-- Previous Page buttonnk --}}
@if ($paginator->onFirstPage())
<button class="btn-pag btn-img" aria-disabled="true" aria-label="@lang('pagination.previous')">
<img src="{{ asset("assets/img/Admin/modules/paginacion-izquierda.png") }}" alt="">
</button>
@else
<a href="{{ $paginator->previousPageUrl() }}" rel="prev" aria-label="@lang('pagination.previous')">
<button class="btn-pag btn-img">
<img src="{{ asset("assets/img/Admin/modules/paginacion-izquierda.png") }}" alt="">
</button>
</a>
@endif

{{-- Pagination Elements --}}
@foreach ($elements as $element)
{{-- "Three Dots" Separator --}}
@if (is_string($element))
<button class="btn-pag" aria-disabled="true">{{ $element }}</button>
@endif

{{-- Array Of buttonnks --}}
@if (is_array($element))
@foreach ($element as $page => $url)
@if ($page == $paginator->currentPage())
<button class="btn-pag btn-img" aria-current="page">{{ $page }}</button>
@else
<button class="btn-pag"><a class="" href="{{ $url }}">{{ $page }}</a></button>
@endif
@endforeach
@endif
@endforeach

{{-- Next Page buttonnk --}}
@if ($paginator->hasMorePages())
<a class="" href="{{ $paginator->nextPageUrl() }}" rel="next" aria-label="@lang('pagination.next')">
<button class="btn-pag btn-img">
<img src="{{ asset("assets/img/Admin/modules/paginacion-derecha.png") }}" alt="">
</button>
</a>
@endif
</ul>
</div>
@endif
8 changes: 7 additions & 1 deletion resources/views/Admin/product/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

{{-- Hoja de estilos de este archivo --}}
<link rel="stylesheet" href="{{ asset("assets/css/Admin/modules/Products/products-styles.css") }}">

{{-- Hoja de estilos para la paginación de registros --}}
<link rel="stylesheet" href="{{ asset("assets/css/Admin/paginacion-registros.css")}}">
</head>
<body>
<!-- Contenido de página -->
Expand Down Expand Up @@ -78,7 +81,7 @@
@endforelse
</table>

<!-- Contenedor de opciones de producto -->
{{-- Contenedor de opciones de producto --}}
<div class="opciones-producto">
<!-- Añadir producto -->
<div class="añadir-prod">
Expand Down Expand Up @@ -114,6 +117,9 @@
</div>
</div>
</section>

{{-- Paginación de registros --}}
{{ $products->onEachSide(3)->links('Admin.pagination') }}
</section>
</body>
</html>
46 changes: 46 additions & 0 deletions resources/views/vendor/pagination/bootstrap-4.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@if ($paginator->hasPages())
<nav>
<ul class="pagination">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.previous')">
<span class="page-link" aria-hidden="true">&lsaquo;</span>
</li>
@else
<li class="page-item">
<a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev" aria-label="@lang('pagination.previous')">&lsaquo;</a>
</li>
@endif

{{-- Pagination Elements --}}
@foreach ($elements as $element)
{{-- "Three Dots" Separator --}}
@if (is_string($element))
<li class="page-item disabled" aria-disabled="true"><span class="page-link">{{ $element }}</span></li>
@endif

{{-- Array Of Links --}}
@if (is_array($element))
@foreach ($element as $page => $url)
@if ($page == $paginator->currentPage())
<li class="page-item active" aria-current="page"><span class="page-link">{{ $page }}</span></li>
@else
<li class="page-item"><a class="page-link" href="{{ $url }}">{{ $page }}</a></li>
@endif
@endforeach
@endif
@endforeach

{{-- Next Page Link --}}
@if ($paginator->hasMorePages())
<li class="page-item">
<a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next" aria-label="@lang('pagination.next')">&rsaquo;</a>
</li>
@else
<li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.next')">
<span class="page-link" aria-hidden="true">&rsaquo;</span>
</li>
@endif
</ul>
</nav>
@endif
88 changes: 88 additions & 0 deletions resources/views/vendor/pagination/bootstrap-5.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
@if ($paginator->hasPages())
<nav class="d-flex justify-items-center justify-content-between">
<div class="d-flex justify-content-between flex-fill d-sm-none">
<ul class="pagination">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<li class="page-item disabled" aria-disabled="true">
<span class="page-link">@lang('pagination.previous')</span>
</li>
@else
<li class="page-item">
<a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev">@lang('pagination.previous')</a>
</li>
@endif

{{-- Next Page Link --}}
@if ($paginator->hasMorePages())
<li class="page-item">
<a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next">@lang('pagination.next')</a>
</li>
@else
<li class="page-item disabled" aria-disabled="true">
<span class="page-link">@lang('pagination.next')</span>
</li>
@endif
</ul>
</div>

<div class="d-none flex-sm-fill d-sm-flex align-items-sm-center justify-content-sm-between">
<div>
<p class="small text-muted">
{!! __('Showing') !!}
<span class="fw-semibold">{{ $paginator->firstItem() }}</span>
{!! __('to') !!}
<span class="fw-semibold">{{ $paginator->lastItem() }}</span>
{!! __('of') !!}
<span class="fw-semibold">{{ $paginator->total() }}</span>
{!! __('results') !!}
</p>
</div>

<div>
<ul class="pagination">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.previous')">
<span class="page-link" aria-hidden="true">&lsaquo;</span>
</li>
@else
<li class="page-item">
<a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev" aria-label="@lang('pagination.previous')">&lsaquo;</a>
</li>
@endif

{{-- Pagination Elements --}}
@foreach ($elements as $element)
{{-- "Three Dots" Separator --}}
@if (is_string($element))
<li class="page-item disabled" aria-disabled="true"><span class="page-link">{{ $element }}</span></li>
@endif

{{-- Array Of Links --}}
@if (is_array($element))
@foreach ($element as $page => $url)
@if ($page == $paginator->currentPage())
<li class="page-item active" aria-current="page"><span class="page-link">{{ $page }}</span></li>
@else
<li class="page-item"><a class="page-link" href="{{ $url }}">{{ $page }}</a></li>
@endif
@endforeach
@endif
@endforeach

{{-- Next Page Link --}}
@if ($paginator->hasMorePages())
<li class="page-item">
<a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next" aria-label="@lang('pagination.next')">&rsaquo;</a>
</li>
@else
<li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.next')">
<span class="page-link" aria-hidden="true">&rsaquo;</span>
</li>
@endif
</ul>
</div>
</div>
</nav>
@endif
46 changes: 46 additions & 0 deletions resources/views/vendor/pagination/default.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@if ($paginator->hasPages())
<nav>
<ul class="pagination">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<li class="disabled" aria-disabled="true" aria-label="@lang('pagination.previous')">
<span aria-hidden="true">&lsaquo;</span>
</li>
@else
<li>
<a href="{{ $paginator->previousPageUrl() }}" rel="prev" aria-label="@lang('pagination.previous')">&lsaquo;</a>
</li>
@endif

{{-- Pagination Elements --}}
@foreach ($elements as $element)
{{-- "Three Dots" Separator --}}
@if (is_string($element))
<li class="disabled" aria-disabled="true"><span>{{ $element }}</span></li>
@endif

{{-- Array Of Links --}}
@if (is_array($element))
@foreach ($element as $page => $url)
@if ($page == $paginator->currentPage())
<li class="active" aria-current="page"><span>{{ $page }}</span></li>
@else
<li><a href="{{ $url }}">{{ $page }}</a></li>
@endif
@endforeach
@endif
@endforeach

{{-- Next Page Link --}}
@if ($paginator->hasMorePages())
<li>
<a href="{{ $paginator->nextPageUrl() }}" rel="next" aria-label="@lang('pagination.next')">&rsaquo;</a>
</li>
@else
<li class="disabled" aria-disabled="true" aria-label="@lang('pagination.next')">
<span aria-hidden="true">&rsaquo;</span>
</li>
@endif
</ul>
</nav>
@endif
36 changes: 36 additions & 0 deletions resources/views/vendor/pagination/semantic-ui.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@if ($paginator->hasPages())
<div class="ui pagination menu" role="navigation">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<a class="icon item disabled" aria-disabled="true" aria-label="@lang('pagination.previous')"> <i class="left chevron icon"></i> </a>
@else
<a class="icon item" href="{{ $paginator->previousPageUrl() }}" rel="prev" aria-label="@lang('pagination.previous')"> <i class="left chevron icon"></i> </a>
@endif

{{-- Pagination Elements --}}
@foreach ($elements as $element)
{{-- "Three Dots" Separator --}}
@if (is_string($element))
<a class="icon item disabled" aria-disabled="true">{{ $element }}</a>
@endif

{{-- Array Of Links --}}
@if (is_array($element))
@foreach ($element as $page => $url)
@if ($page == $paginator->currentPage())
<a class="item active" href="{{ $url }}" aria-current="page">{{ $page }}</a>
@else
<a class="item" href="{{ $url }}">{{ $page }}</a>
@endif
@endforeach
@endif
@endforeach

{{-- Next Page Link --}}
@if ($paginator->hasMorePages())
<a class="icon item" href="{{ $paginator->nextPageUrl() }}" rel="next" aria-label="@lang('pagination.next')"> <i class="right chevron icon"></i> </a>
@else
<a class="icon item disabled" aria-disabled="true" aria-label="@lang('pagination.next')"> <i class="right chevron icon"></i> </a>
@endif
</div>
@endif
Loading

0 comments on commit 7130881

Please sign in to comment.