Workflow
Datasource Relationship

This example demonstrates a Relationship with a Datasource.

ID
Name
Kitchen
1
Arkansas Possum Pie
MG
2
Albacore Tuna Melt
RJ
3
борщ
MG
4
Bacalhau com natas
MG
5
Baba Ghanoush
RJ
6
Bacon Cheeseburger
BA
7
Baked potato
SP
8
Baklava
RJ
9
Bangers and mash
SP
10
Black Pudding
RJ
11
Blue cheese dressing
BA
12
Boulliabaise
SP
13
Bread
BA
14
Breaded shrimp
RJ
15
Breakfast burrito
BA
16
Brisket
SP
17
Brunswick stew
SP
18
Bruschetta
MG
19
Buffalo Wings
RJ
20
Buffalo burger
RJ
21
Buffalo wing
BA
22
Calamari
SP
23
Carne pizzaiola
SP
24
Caviar
SP
25
Ceviche
RJ
26
Cheesecake
RJ
27
Chicken Biryani
BA
28
Chicken Tikka Masala
MG
29
Chicken and waffles
RJ
30
Chicken bog
MG
31
Chicken fingers
SP
32
Chile Relleno
RJ
33
Chili con carne
MG
34
Chili dog
MG
35
Chimichanga
RJ
36
Chinese food
RJ
37
Chips and dip
MG
38
Choco pie
SP
39
Chocolate Brownie
MG
41
Chocolate cheesecake
BA
42
Chowder
BA
43
Churrasco
MG
44
Cinnamon Roll
RJ
45
Coleslaw
MG
46
Coq Au Vin
SP
47
Cordon bleu
RJ
48
Currywurst
RJ
49
Eggo
MG
50
Eggs Benedict
MG
51
Eggs Neptune
RJ
52
Empanada
SP
53
Energy bar
BA
54
Escargot
SP
55
Fajitas
BA
56
Falafel
MG
57
Fattoush Salad
MG
58
Fish Tacos
BA
59
Fish and Chips!
SP
60
Flan
RJ
61
Fortune cookie
MG
62
Francesinha
RJ
63
French Onion Soup
MG
64
Fries
RJ
65
Frito Pie
MG
66
Fry sauce
BA
67
Funnel Cake
RJ
68
Garden salad
SP
69
Garlic bread
SP
70
Gazpacho
RJ
71
Goulash
BA
72
Greek salad
SP
73
Grilled Snake
MG
74
γύρος
MG
75
Gumbo
SP
76
Gyoza
RJ
77
Huevos Rancheros
SP
78
Hummus
RJ
79
Ice Cream
RJ
80
Key Lime Pie
BA
81
Kimchi
BA
82
Kobe Beef
BA
83
Kung Pao Chicken
MG
84
Laksa
BA
85
Lasagna
SP
86
Liver and onions
RJ
87
Lobster Newberg
MG
88
Lobster roll
RJ
89
London broil
SP
90
Lorna Doone
SP
91
Low Country Boil
MG
92
Macaroni and Cheese
SP
93
Macaroni and cheese
SP
94
Macaroni salad
BA
95
Maine Lobster
SP
96
Mango and Sticky Rice
SP
97
Maple Bacon Doughnut
RJ
98
Maple bacon donut
MG
99
Maraca pie
SP
100
Margherita Pizza
RJ
101
Mashed potato
MG
102
Mashed pumpkin
SP
103
Massaman Curry
BA
104
Matzo Ball Soup
SP
105
Meat Feast Pizza
BA
106
Meatcake
RJ
107
Meatloaf
MG
108
Milkshake
RJ
109
Mini pizzas
BA
110
Mozzarella sticks
BA
111
Muffuletta
BA
112
Mulligan stew
SP
113
Naan
MG
114
New York-Style Pizza
SP
115
Onion Rings
RJ
116
Oreo
SP
117
Osso Buco
BA
118
Paella
SP
119
Pancakes
SP
120
Parma Ham
SP
121
Pasta salad
SP
122
Pastel de Nata
RJ
123
Pastrami
MG
124
Pastrami on Rye
BA
125
Patty
SP
126
Peixada da chef Nábia
MG
127
Peanut butter
SP
128
Pemmican
RJ
129
Pepperoni
RJ
130
Pepperoni Pizza
MG
131
Phaal
MG
132
Philly Cheese Steak
MG
133
Polenta
SP
134
Potato Wedges
SP
135
Potato salad
SP
136
Potato skins
MG
137
Potato wedges
SP
138
Poutine
RJ
139
Quesadilla
RJ
140
Ratatouille
SP
141
Ribs
MG
142
Risotto
BA
143
Roasted Bone Marrow
SP
144
Roasted Chickpeas
MG
145
Samosa
RJ
146
Schnitzel
MG
147
Scrapple
MG
148
Sloppy joe
SP
149
Souvlaki
MG
150
Spaghetti Bolognese
SP
151
Spaghetti and Meatballs
RJ
152
Spanish rice
BA
153
Spring Rolls
BA
154
Squab
RJ
155
St. Paul Sandwich
SP
156
Steak Tartare
SP
157
Steak sandwich
BA
158
Steak sauce
MG
159
Steamed clams
BA
160
Stroganoff
SP
161
Stuffed ham
SP
162
Stuffed peppers
BA
163
Stuffed zucchini
BA
164
Succotash
MG
165
Suckling Pig
SP
166
Supreme pizza
RJ
167
Surf and turf
BA
168
Sushi
MG
169
Sueli's Sushi Boat
RJ
170
Sweet Potato Fries
SP
171
Sweetbreads
SP
172
Swiss steak
BA
173
Tagine
RJ
174
Tamales
SP
175
Tetrazzini
SP
176
Texas Toast
RJ
177
Thousand Island dressing
MG
178
Tin Roof Ice Cream
SP
179
Toaster Strudel
MG
180
Tomato compote
BA
181
Tres Leches Cake
MG
182
Tuna Pizza
BA
183
Tuna casserole
RJ
184
Turducken
RJ
185
Turkish Delight
MG
186
Vitão's Chocolate pie
SP
187
Veggie Pizza
MG
188
Venison
MG
189
Vichyssoise
MG
190
Waffle
SP
191
Wasabi Peas
MG
192
White chocolate cookie
RJ
193
Yeung Chow fried rice
BA
Disclaimer: Table data is randomly generated for illustrative purposes only. The information here is not a reflection of the actual market and does not constitute business, financial, or medical advice.
<?php
 
namespace App\Livewire\Examples\DatasourceRelationshipTable;
 
use App\Models\Dish;
use Illuminate\Database\Eloquent\Builder;
use PowerComponents\LivewirePowerGrid\Column;
use PowerComponents\LivewirePowerGrid\PowerGrid;
use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\PowerGridFields;
 
final class DatasourceRelationshipTable extends PowerGridComponent
{
public function datasource(): ?Builder
{
return Dish::query()->with('kitchen');
}
 
public function fields(): PowerGridFields
{
return PowerGrid::fields()
->add('id')
->add('name')
->add('kitchen_description', fn ($dish) => e($dish->kitchen->description));
}
 
public function columns(): array
{
return [
Column::make('ID', 'id'),
 
Column::make('Name', 'name')
->sortable()
->searchable(),
 
Column::make('Kitchen', 'kitchen_description'),
];
}
}
Code highlighting provided by Torchlight.dev

Here you can find all relevant packages installed on this demo.

Name
Version
Description
laravel/framework
v11
The Laravel Framework.
livewire/livewire
v3.4.12
A front-end framework for Laravel.
openspout/openspout
v4.24.0
PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way
power-components/livewire-powergrid
v5.6.3
PowerGrid generates Advanced Datatables using Laravel Livewire.