Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
zofe committed Jan 14, 2025
1 parent 909fc82 commit 611b837
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 63 deletions.
5 changes: 4 additions & 1 deletion config/livewire.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@

return [
'legacy_model_binding' => true,
'layout' => 'layout::frontend'
'layout' => 'layout::frontend',

'pagination_theme' => 'pagination',

];
1 change: 1 addition & 0 deletions resources/views/components/pagination.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//'perPage' => $__data['_instance']->editRoute,
])
@if($items)

@if(method_exists($items,'links'))
<div class="d-flex justify-content-between mt-3">
<div class="form-inline">
Expand Down
77 changes: 77 additions & 0 deletions resources/views/livewire/pagination.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
@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>
<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
7 changes: 4 additions & 3 deletions src/RapydServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Zofe\Rapyd;

use Illuminate\Foundation\Http\Events\RequestHandled;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
Expand Down Expand Up @@ -49,9 +50,7 @@ public function boot()

$this->loadViewsFrom(resource_path('views/vendor/rapyd'), 'rpd');
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'rpd');



$this->loadViewsFrom(__DIR__ . '/../resources/views/livewire', 'livewire');

Blade::directive('rapydScripts', function () {
$scripts = "<script src=\"{{ asset('vendor/rapyd/rapyd.js') }}\"></script>\n";
Expand Down Expand Up @@ -92,6 +91,8 @@ public function boot()
});


//Paginator::defaultView('pagination');

//Artisan::call('rpd:make:home');

/*
Expand Down
5 changes: 4 additions & 1 deletion src/Traits/WithDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

trait WithDataTable
{
use WithPaginationCustom;
//use WithPaginationCustom;
use \Livewire\WithPagination;
use WithSorting;

public $perPage = 10;
}
115 changes: 57 additions & 58 deletions src/Traits/WithPaginationCustom.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,62 +10,61 @@ trait WithPaginationCustom
use HandlesPagination;

public $perPage = 10;
protected $paginationTheme = 'bootstrap';

public function pageName(): string
{
if (property_exists($this, 'pageName')) {
if (! isset($this->{$this->pageName})) {
$this->{$this->pageName} = 1;
}

return $this->pageName;
} else {
return 'page';
}
}

public function getQueryString()
{
return array_merge([$this->pageName() => ['except' => 1]], $this->queryString);
}

public function initializeWithPagination()
{
$this->{$this->pageName()} = $this->resolvePage();

Paginator::currentPageResolver(function () {
return $this->{$this->pageName()};
});

Paginator::defaultView($this->paginationView());
}


public function previousPage($pageName = 'page')
{
$this->setPage($this->{$this->pageName()} - 1);
}

public function nextPage($pageName = 'page')
{
$this->setPage($this->{$this->pageName()} + 1);
}

public function setPage($page, $pageName = 'page')
{
$this->{$this->pageName()} = $page;
}

public function resolvePage()
{
return request()->query($this->pageName(), $this->{$this->pageName()});
}

public function getPublicPropertiesDefinedBySubClass()
{
return tap(parent::getPublicPropertiesDefinedBySubClass(), function (&$props) {
$props[$this->pageName()] = $this->{$this->pageName()};
});
}
// protected $paginationTheme = 'bootstrap';
//
// public function pageName(): string
// {
// if (property_exists($this, 'pageName')) {
// if (! isset($this->{$this->pageName})) {
// $this->{$this->pageName} = 1;
// }
//
// return $this->pageName;
// } else {
// return 'page';
// }
// }
//
// public function getQueryString()
// {
// return array_merge([$this->pageName() => ['except' => 1]], $this->queryString);
// }
//
// public function initializeWithPagination()
// {
// $this->{$this->pageName()} = $this->resolvePage();
//
// Paginator::currentPageResolver(function () {
// return $this->{$this->pageName()};
// });
// Paginator::defaultView($this->paginationView());
// }
//
//
// public function previousPage($pageName = 'page')
// {
// $this->setPage($this->{$this->pageName()} - 1);
// }
//
// public function nextPage($pageName = 'page')
// {
// $this->setPage($this->{$this->pageName()} + 1);
// }
//
// public function setPage($page, $pageName = 'page')
// {
// $this->{$this->pageName()} = $page;
// }
//
// public function resolvePage()
// {
// return request()->query($this->pageName(), $this->{$this->pageName()});
// }
//
// public function getPublicPropertiesDefinedBySubClass()
// {
// return tap(parent::getPublicPropertiesDefinedBySubClass(), function (&$props) {
// $props[$this->pageName()] = $this->{$this->pageName()};
// });
// }
}

0 comments on commit 611b837

Please sign in to comment.