Download the PHP package aashan/livewire-table without Composer
On this page you can find all versions of the php package aashan/livewire-table. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package livewire-table
Livewire Tables
Livewire tables is an add-on for your laravel/livewire project that lets you beautiful data tables within a matter of minutes. It comes with Table and Column classes that handle the logic behind your data tables.
Installation
Usage
After installing the package, here is a step-by-step guide on how you can use livewire table.
- Create a class
UsersTableinside the livewire components directory (app/Http/Livewire) -
Open the
\App\Http\Livewire\UsersTableclass and make it as follows - Open the view where you want to show the table and add the livewire component name
That's it. You should see a table in your view.
But wait?
You might be wondering why the table is empty. It's because we haven't added any columns yet. Remember the columns method that we just left empty? Now it's time to fill it up with actual columns.
Now when you re-fresh your page, you should be able to see the columns with their values.
Making columns sortable, searchable and transforming data
Very easy, Just use sortable, searchable and transform methods on the column class.
Example:
Warning For
searchableandfilterablemethods, they should always haveonSearchandonFiltermethods present within the column. If they are not present, searching and filtering won't work.
API
- \LivewireTable\Components\Table::class
public $perPage- Determines the number of rows shown per page
- \LivewireTable\Table\Column::class
- Properties
$key: Usually corresponds to the actual database column name$label: UI heading for the database column$searchable: Determines if the column is searchable$sortable: Determines if the column is sortable$filterable: Determines if the column is filterable$transformClosure: Action Class name or closure that transforms the data$searchClosure: Action Class name or closure that handles search results$filterClosure: Similar to searchClosure, only difference is it handles filters- Methods
public function searchable(bool $value = true): static: Sets the$searchablepropertypublic function sortable(bool $value = true): static: Sets the$sortablepropertypublic function filterable(bool $value = true): static: Sets the$filterablepropertypublic function transform($row): string: Transforms the given row with the transformation closurepublic function onSearch(callable|string $action): static: Sets$searchClosurepropertypublic function onFilter(callable|string $action): static: Sets$filtetrClosurepropertypublic function onTransform(callable|string $action): static: Sets$transformClosureproperty