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