Laravel Livewire Tables Documentation

🎉 Enjoying this package? Consider sponsoring me on GitHub or buying me a beer.

This is the documentation for v3. You can switch versions in the menu at the top. Check your current version with the following command:

composer show rappasoft/laravel-livewire-tables


Out of the box the columns support hasOne, belongsTo, and MorphOne relationships for display, sorting, and searching. The component will automatically join the necessary tables.

To call these relationships, just use the relationship dot-notation string as the field name:

1protected $model = User::class;
3// ...
5public function columns(): array {
6 return [
7 // Looks for the address column on the address relationship of User.
8 // $user->address->address
9 Column::make('Address', 'address.address'),
11 // Looks for $user->address->group->name
12 Column::make('Address Group', ''),
14 // Looks for $user->address->group->city->name
15 Column::make('Group City', ''),
16 ];

The above will join the necessary tables as well as alias the columns for selecting, sorting, searching, etc.:

1SELECT `addresses`.`address` AS `address.address`,
2 `address_groups`.`name` AS ``,
3 `cities`.`name` AS ``
4FROM `users`
5 LEFT JOIN `addresses`
6 ON `addresses`.`user_id` = `users`.`id`
7 LEFT JOIN `address_groups`
8 ON `addresses`.`address_group_id` = `address_groups`.`id`
9 LEFT JOIN `cities`
10 ON `address_groups`.`city_id` = `cities`.`id`