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

One Of Many Example

When trying to retrieve "OneOfMany", you may experience duplicate records.

Core functionality for this will be added in due course, this is simply a work-around.

In the meantime, to avoid this, you can use the following approach.

This example assumes two Models: User -> HasMany -> Things

Models

User

id name created_at updated_at etc

1public function things(): \Illuminate\Database\Eloquent\Relations\HasMany
2{
3 return $this->hasMany(Things::class);
4}

Things

id name user_id created_at updated_at

Table

The following is the table code for this example, and retrieves the most recently created "Thing"

Column

1Column::make('Latest Thing')
2->label(
3 fn ($row, Column $column) => $row->things->first()->name
4),

Builder

1public function builder(): Builder {
2 
3 return User::query()->with(['things' => function ($query) {
4 $query->select(['id','user_id','name'])->orderBy('created_at', 'desc')->limit(1);
5 }]);
6 
7}

Core functionality for this will be added in due course, this is simply a work-around.