rappasoft/laravel-livewire-tables
Laravel Livewire Tables provides dynamic, feature-rich data tables for Laravel Livewire with sorting, searching, filtering, pagination, bulk actions, and Bootstrap/Tailwind support. Build reusable table components backed by Eloquent queries.
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
id name created_at updated_at etc
public function things(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(Things::class);
}
id name user_id created_at updated_at
The following is the table code for this example, and retrieves the most recently created "Thing"
Column::make('Latest Thing')
->label(
fn ($row, Column $column) => $row->things->first()->name
),
public function builder(): Builder {
return User::query()->with(['things' => function ($query) {
$query->select(['id','user_id','name'])->orderBy('created_at', 'desc')->limit(1);
}]);
}
Core functionality for this will be added in due course, this is simply a work-around.
How can I help you explore Laravel packages today?