Skip to content

How to pass row data (or the model) to the Details view? #609

Answered by dansysanalyst
eswachsman asked this question in Q&A
Discussion options

You must be logged in to vote

HI @eswachsman,

Thank you for your question. You can access your model data with the $row variable.

<?php

use PowerComponents\LivewirePowerGrid\Detail;

public function setUp(): array
    {
        $this->showCheckBox();

        return [
          //...

            Detail::make()
                ->view('components.detail')
                ->options(['message' => 'hello world'])
                ->showCollapseIcon(),
        ];
    }

And I've created a view with:

<!-- File: resources/views/components/detail.blade.php -->

<div>
    <p>
        Dish has {{ $row->calories }} ({{ $options['message'] }})
    </p>
</div>

Resulting in:


This example was added to PowerGrid-Demo repository and …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@eswachsman
Comment options

Answer selected by eswachsman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #608 on September 04, 2022 20:04.