Skip to content

Commit

Permalink
label localization for pagination and sweetalert confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
iqbaleff214 committed May 24, 2024
1 parent b6dd70b commit 4249c43
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ public function boot(): void
View::share('menuData', $verticalMenuData);
View::share('languages', config('app.available_locales'));

Paginator::useBootstrapFive();
Paginator::defaultView('components.pagination');
}
}
9 changes: 9 additions & 0 deletions lang/en/label.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,13 @@
'enter_your_email_to_reset_password' => 'Enter your email and we will send you a link to reset your password.',
'reset_password' => 'Reset password',
'please_enter_your_new_password' => 'Please enter your new password.',
'search' => 'Search...',
'edit' => 'Edit',
'delete' => 'Delete',
'warning' => 'Warning',
'are_you_sure' => 'Are you sure?',
'yes_i_am' => 'Yes, I am!',
'cancel' => 'Cancel',
'new' => 'New',
'detail' => 'Detail',
];
4 changes: 4 additions & 0 deletions lang/en/pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@

'previous' => '« Previous',
'next' => 'Next »',
'showing' => 'Showing',
'to' => 'to',
'of' => 'of',
'results' => 'results',

];
9 changes: 9 additions & 0 deletions lang/id/label.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,13 @@
'enter_your_email_to_reset_password' => 'Masukkan email kamu dan akan kami kirimkan link buat reset password kamu',
'reset_password' => 'Reset Password',
'please_enter_your_new_password' => 'Silakan masukkan password baru kamu',
'search' => 'Cari...',
'edit' => 'Edit',
'delete' => 'Hapus',
'warning' => 'Peringatan',
'are_you_sure' => 'Apakah Anda yakin?',
'yes_i_am' => 'Iya, saya yakin!',
'cancel' => 'Batalkan',
'new' => 'Baru',
'detail' => 'Detail',
];
4 changes: 4 additions & 0 deletions lang/id/pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@

'previous' => '« Sebelumnya',
'next' => 'Berikutnya »',
'showing' => 'Menampilkan',
'to' => 'sampai',
'of' => 'dari',
'results' => 'hasil',

];
88 changes: 88 additions & 0 deletions resources/views/components/pagination.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">
{!! __('pagination.showing') !!}
<span class="fw-semibold">{{ $paginator->firstItem() }}</span>
{!! __('pagination.to') !!}
<span class="fw-semibold">{{ $paginator->lastItem() }}</span>
{!! __('pagination.of') !!}
<span class="fw-semibold">{{ $paginator->total() }}</span>
{!! __('pagination.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
8 changes: 4 additions & 4 deletions resources/views/layouts/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@
function confirmSubmit(e, form) {
e.preventDefault();
Swal.fire({
title: 'Perhatian',
text: 'Apakah Anda yakin?',
title: "{{ __('label.warning') }}",
text: "{{ __('label.are_you_sure') }}",
icon: 'question',
showCancelButton: true,
confirmButtonText: 'Iya, saya yakin!',
cancelButtonText: 'Batalkan'
confirmButtonText: "{{ __('label.yes_i_am') }}",
cancelButtonText: "{{ __('label.cancel') }}",
}).then((result) => {
if (result.isConfirmed) {
form.submit();
Expand Down

0 comments on commit 4249c43

Please sign in to comment.