Workflow
Datasource Relationship

This example demonstrates a Relationship with a Datasource.

ID
Name
Kitchen
1
Arkansas Possum Pie
MG
2
Albacore Tuna Melt
BA
3
ะฑะพั€ั‰
MG
4
Bacalhau com natas
BA
5
Baba Ghanoush
RJ
6
Bacon Cheeseburger
RJ
7
Baked potato
MG
8
Baklava
BA
9
Bangers and mash
RJ
10
Black Pudding
SP
11
Blue cheese dressing
RJ
12
Boulliabaise
RJ
13
Bread
BA
14
Breaded shrimp
MG
15
Breakfast burrito
SP
16
Brisket
BA
17
Brunswick stew
RJ
18
Bruschetta
RJ
19
Buffalo Wings
SP
20
Buffalo burger
RJ
21
Buffalo wing
MG
22
Calamari
BA
23
Carne pizzaiola
SP
24
Caviar
MG
25
Ceviche
BA
26
Cheesecake
SP
27
Chicken Biryani
RJ
28
Chicken Tikka Masala
BA
29
Chicken and waffles
RJ
30
Chicken bog
MG
31
Chicken fingers
BA
32
Chile Relleno
RJ
33
Chili con carne
MG
34
Chili dog
SP
35
Chimichanga
MG
36
Chinese food
SP
37
Chips and dip
SP
38
Choco pie
RJ
39
Chocolate Brownie
MG
41
Chocolate cheesecake
MG
42
Chowder
MG
43
Churrasco
RJ
44
Cinnamon Roll
RJ
45
Coleslaw
BA
46
Coq Au Vin
BA
47
Cordon bleu
BA
48
Currywurst
RJ
49
Eggo
BA
50
Eggs Benedict
BA
51
Eggs Neptune
SP
52
Empanada
RJ
53
Energy bar
RJ
54
Escargot
BA
55
Fajitas
MG
56
Falafel
MG
57
Fattoush Salad
MG
58
Fish Tacos
RJ
59
Fish and Chips!
SP
60
Flan
SP
61
Fortune cookie
RJ
62
Francesinha
SP
63
French Onion Soup
MG
64
Fries
RJ
65
Frito Pie
BA
66
Fry sauce
RJ
67
Funnel Cake
SP
68
Garden salad
MG
69
Garlic bread
BA
70
Gazpacho
RJ
71
Goulash
MG
72
Greek salad
SP
73
Grilled Snake
MG
74
ฮณฯฯฮฟฯ‚
SP
75
Gumbo
SP
76
Gyoza
RJ
77
Huevos Rancheros
RJ
78
Hummus
SP
79
Ice Cream
SP
80
Key Lime Pie
RJ
81
Kimchi
BA
82
Kobe Beef
MG
83
Kung Pao Chicken
BA
84
Laksa
SP
85
Lasagna
MG
86
Liver and onions
SP
87
Lobster Newberg
MG
88
Lobster roll
BA
89
London broil
BA
90
Lorna Doone
RJ
91
Low Country Boil
SP
92
Macaroni and Cheese
BA
93
Macaroni and cheese
BA
94
Macaroni salad
BA
95
Maine Lobster
RJ
96
Mango and Sticky Rice
RJ
97
Maple Bacon Doughnut
RJ
98
Maple bacon donut
SP
99
Maraca pie
SP
100
Margherita Pizza
RJ
101
Mashed potato
SP
102
Mashed pumpkin
SP
103
Massaman Curry
BA
104
Matzo Ball Soup
SP
105
Meat Feast Pizza
BA
106
Meatcake
BA
107
Meatloaf
MG
108
Milkshake
BA
109
Mini pizzas
SP
110
Mozzarella sticks
BA
111
Muffuletta
BA
112
Mulligan stew
MG
113
Naan
MG
114
New York-Style Pizza
RJ
115
Onion Rings
SP
116
Oreo
SP
117
Osso Buco
RJ
118
Paella
BA
119
Pancakes
RJ
120
Parma Ham
MG
121
Pasta salad
RJ
122
Pastel de Nata
BA
123
Pastrami
MG
124
Pastrami on Rye
BA
125
Patty
RJ
126
Peixada da chef Nรกbia
MG
127
Peanut butter
MG
128
Pemmican
BA
129
Pepperoni
SP
130
Pepperoni Pizza
MG
131
Phaal
MG
132
Philly Cheese Steak
BA
133
Polenta
BA
134
Potato Wedges
RJ
135
Potato salad
MG
136
Potato skins
RJ
137
Potato wedges
BA
138
Poutine
SP
139
Quesadilla
BA
140
Ratatouille
MG
141
Ribs
MG
142
Risotto
BA
143
Roasted Bone Marrow
RJ
144
Roasted Chickpeas
SP
145
Samosa
RJ
146
Schnitzel
MG
147
Scrapple
RJ
148
Sloppy joe
BA
149
Souvlaki
SP
150
Spaghetti Bolognese
SP
151
Spaghetti and Meatballs
BA
152
Spanish rice
BA
153
Spring Rolls
MG
154
Squab
SP
155
St. Paul Sandwich
MG
156
Steak Tartare
BA
157
Steak sandwich
MG
158
Steak sauce
BA
159
Steamed clams
BA
160
Stroganoff
RJ
161
Stuffed ham
SP
162
Stuffed peppers
RJ
163
Stuffed zucchini
RJ
164
Succotash
RJ
165
Suckling Pig
MG
166
Supreme pizza
SP
167
Surf and turf
RJ
168
Sushi
SP
169
Sueli's Sushi Boat
MG
170
Sweet Potato Fries
SP
171
Sweetbreads
BA
172
Swiss steak
MG
173
Tagine
BA
174
Tamales
BA
175
Tetrazzini
MG
176
Texas Toast
RJ
177
Thousand Island dressing
BA
178
Tin Roof Ice Cream
MG
179
Toaster Strudel
RJ
180
Tomato compote
RJ
181
Tres Leches Cake
BA
182
Tuna Pizza
SP
183
Tuna casserole
RJ
184
Turducken
SP
185
Turkish Delight
MG
186
Vitรฃo's Chocolate pie
RJ
187
Veggie Pizza
BA
188
Venison
RJ
189
Vichyssoise
MG
190
Waffle
MG
191
Wasabi Peas
RJ
192
White chocolate cookie
MG
193
Yeung Chow fried rice
SP
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.
๐Ÿ”Ž View on GitHub
<?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.5.4
A front-end framework for Laravel.
openspout/openspout
v4.24.3
PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way
power-components/livewire-powergrid
5.x-dev
PowerGrid generates Advanced Datatables using Laravel Livewire.