akyos / ux-pagination
A Symfony bundle to paginate table in live Component
Installs: 14
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Language:CSS
Requires
- php: ^8.2
- knplabs/knp-paginator-bundle: ^6.0
- symfony/orm-pack: ^2.4
- symfony/ux-icons: ^2.21
- symfony/ux-live-component: ^2.21
Requires (Dev)
- symfonycasts/tailwind-bundle: ^0.6.0
This package is auto-updated.
Last update: 2024-10-30 16:02:14 UTC
README
A Symfony bundle to paginate table in live Component
Sample:
Php file
<?php namespace App\Twig\Components\Product; use Akyos\UXFilters\Class\Text; use Akyos\UXFilters\Trait\ComponentWithFilterTrait; use Akyos\UXPagination\Trait\ComponentWithPaginationTrait; use App\Entity\Product; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\UX\LiveComponent\Attribute\AsLiveComponent; use Symfony\UX\LiveComponent\DefaultActionTrait; #[AsLiveComponent] final class Index extends AbstractController { use DefaultActionTrait; use ComponentWithFilterTrait; use ComponentWithPaginationTrait; public function __construct() { $this->repository = Product::class; $this->setLimit(3); } protected function setFilters(): iterable { yield (new Text('name', 'Name'))->setSearchType('like')->setParams([ 'entity.name', 'entity.description', ]); } }
Template
<div{{ attributes }}> {{ form(formFilters) }} {% for product in elements %} <div class="product"> <div class="product__content"> <h3 class="product__title">{{ product.name }}</h3> <p class="product__price">{{ product.description|raw }}</p> <p class="product__price">{{ product.price }}</p> </div> </div> {% endfor %} {{ pagination|raw }} </div>