diff --git a/src/resources/views/widgets/relation_panel.blade.php b/src/resources/views/widgets/relation_panel.blade.php index 3a814a2..558cc1d 100644 --- a/src/resources/views/widgets/relation_panel.blade.php +++ b/src/resources/views/widgets/relation_panel.blade.php @@ -1,15 +1,16 @@ @php - if(!isset($entry) || $entry->{$widget['name']} === null){ + $entry_relation = data_get($entry, $widget['name']); + if(!isset($entry) || $entry_relation === null){ return; } if(isset($widget['visible']) && is_callable($widget['visible'])){ - if(!$widget['visible']($entry->{$widget['name']})){ + if(!$widget['visible']($entry_relation)){ return; } } if(!isset($widget['fields'])){ $widget['fields'] = []; - foreach ($entry->{$widget['name']}->getFillable() as $propertyName){ + foreach ($entry_relation->getFillable() as $propertyName){ $widget['fields'][] = [ 'label' => $crud->makeLabel($propertyName), 'name' => $propertyName, @@ -28,6 +29,8 @@ if (!isset($widget['buttons']) || $widget['buttons'] !== false) { $widget['buttons'] = true; } + + @endphp
@@ -39,16 +42,16 @@ @foreach($widget['fields'] as $field) @php if(isset($field['visible']) && is_callable($field['visible'])){ - if(!$field['visible']($entry->{$widget['name']}->{$widget['name']})){ + if(!$field['visible']($entry_relation)){ continue; } } $value = ''; if(isset($field['closure'])){ - $value = $field['closure']($entry->{$widget['name']}); + $value = $field['closure']($entry_relation); } if(isset($field['name'])){ - $value = data_get($entry->{$widget['name']}, $field['name']); + $value = data_get($entry_relation, $field['name']); } @endphp @@ -67,13 +70,13 @@ @if ($widget['button_show'] === true) - {$widget['name']}->id . "/show") }}" + id . "/show") }}" class="btn btn-sm btn-link"> {{ trans('backpack::crud.preview') }} @endif @if ($widget['button_edit'] === true) - {$widget['name']}->id . "/edit") }}" + id . "/edit") }}" class="btn btn-sm btn-link"> {{ trans('backpack::crud.edit') }}