Follow the steps below to upgrade the package.
If you do use the laravel-html-helper in your projet without having installed through composer, you should add it.
However, please note that this package is now useless for all my packages and has been abandoned, so it will not be maintained anymore.
In order to reduce the high complexity involved by the HTTP requests data handling, and in order to plug several additional features, I chose to rebuild this package to work with Livewire.
As so, you will have to install it properly before using this package : https://laravel-livewire.com/docs/installation.
The package config file changed entirely. If you published it, you'll have to delete it, re-publish it and reapply your changes.
Here are the words and sentences that were translatable in the v4:
CreateShowEditDestroyNumber of rowsSearch by:Reset researchActionsNo results were found.Showing results <b>:start</b> to <b>:stop</b> on <b>:total</b>There are new translations in v5 that you'll find here, you should add them to your locale json file if you need to get them translated.
Templates have changed entirely as the package has migrated to work with Livewire. If you published them, you'll have to re-publish them and reapply your changes.
Table configuration signature has changed and now look this way:
namespace App\Tables;
use Okipa\LaravelTable\Table;
use Okipa\LaravelTable\Column;
use Okipa\LaravelTable\Result;
use Okipa\LaravelTable\Abstracts\AbstractTableConfiguration;
class UsersTable extends AbstractTableConfiguration
{
protected function table(): Table
{
return Table::make()->model(<model_namespace>);
}
protected function columns(): array
{
return [
Column::make('<model_attribute>')->...
// ... Other column declarations
];
}
// Optional: do not declare this method if no results are displayed on the table
protected function results(): array
{
return [
Result::make()->...
// ... Other result declarations
];
}
}
As so, the following changes must be reported in your table configurations:
use Okipa\LaravelTable\Abstracts\AbstractTable by use Okipa\LaravelTable\Abstracts\AbstractTableConfiguration;extends AbstractTable by extends AbstractTableConfigurationreturn (new Table())-> by return Table::make()-> at the beginning of the table() functionprotected function columns(Table $table): void function signatures by protected function columns(): array
$table->column( by Column::make( at the beginning of the columns() function
protected function results(Table $table): void function signatures by protected function results(): array$table->result( by Result::make() at the beginning of the results() function
->identifier( declaration, it is now useless->request( declaration, it is now useless->routes( has been removed
ìndex route, it is now useless as the whole table is handled with Livewirecreate route declarations from the ->routes() method->headAction(new CreateHeadAction(route('user.create')))->rowActions(fn(User $user) => [])show route declarations from the ->routes() methodShowRowAction instead following this example: new ShowRowAction(route('user.show', $user))edit route by declaring a EditRowAction instead following this example: new EditRowAction(route('user.edit', $user))destroy route by declaring a DestroyRowAction instead following this example: new DestroyRowAction()destroy route declaration may now be useless, you may delete them->rowsNumber( declaration by ->numberOfRowsPerPageOptions( and update the provided argument to match its new signature->activateRowsNumberDefinition( declaration by ->enableNumberOfRowsPerPageChoice(->appendData( declaration, it is now useless->containerClasses( declaration->tableClasses( declaration->trClasses( declaration->thClasses( declaration->tdClasses( declaration->rowsConditionalClasses( declaration by rowClass and update the provided argument to match its new signature->destroyConfirmationHtmlAttributes( declaration
->disableRows( declaration
->tableTemplate( declaration->theadTemplate( declaration->rowsSearchingTemplate( declaration->rowsNumberDefinitionTemplate( declaration->createActionTemplate( declaration->columnTitlesTemplate( declaration->tbodyTemplate( declaration->showActionTemplate( declaration->editActionTemplate( declaration->destroyActionTemplate( declaration->resultsTemplate( declaration->tfootTemplate( declaration->navigationStatusTemplate( declaration->paginationTemplate( declaration->classes( declaration->sortable( has changed its signature: make sure implementations are compatible with it
->sortByDefault('desc') // 'asc' by defaultsearchable has changed its signaturedateTimeFormat declaration
->dateTimeFormat('d/m/Y H:i', 'Europe/Paris') declarations by ->format(new DateFormatter('d/m/Y H:i', 'Europe/Paris'))buttonlinkprependHtmlappendsHtmlvaluehtmlhtml has been removed
classes has been removedYou do not have to instantiate your configuration in your controller anymore.
You should search for $table = or ->setup() in your controller and remove all these instantiations.
Then, replace all the {{ $table }} calls from your views by the Livewire dedicated component with you table configuration passed in parameter, as explained here:
<livewire:table :config="App\Tables\UsersTable::class"/>
If you wish to pass data to your table configuration, do it this way.
You'll have to add a few lines of JavaScript to your project to handle table action confirmations and feedbacks.
You'll also have to install the Livewire Sortable Plugin on your project to allow the built-in columns drag-and-drop-reordering to work properly.
You have now completed upgrading your tables and all features from v4 should be migrated.
However, new features are now available for you to use.
Make sur you have read the new provided documentation to take advantage of them!
See all change with the comparison tool.
If you see any forgotten and undocumented change, please submit a PR to add them to this upgrade guide.
How can I help you explore Laravel packages today?