How to show the data from relationship? #580
Answered
by
akulmehta
anonymouse703
asked this question in
Q&A
-
We usually display relationship data something like this
And then in the documents it says to do it like this
but how to display the relationship in the row? |
Beta Was this translation helpful? Give feedback.
Answered by
akulmehta
Aug 23, 2022
Replies: 1 comment 1 reply
-
Check this example: https://github.com/Power-Components/powergrid-demo/blob/main/app/Http/Livewire/DishesTable.php You need to create columns in the /*** KITCHEN ***/
->addColumn('kitchen_id', function (Dish $dish) {
return $dish->kitchen_id;
})
->addColumn('kitchen_name', function (Dish $dish) {
return $dish->kitchen->name;
}) next you need to render the columns using the Column::add()
->title(__('Kitchen'))
->field('kitchen_name', 'kitchens.name')
->sortable('kitchens.name'), |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
anonymouse703
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Check this example: https://github.com/Power-Components/powergrid-demo/blob/main/app/Http/Livewire/DishesTable.php
You need to create columns in the
addColumns()
method. Example:next you need to render the columns using the
columns()
method. Example: