Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
izica committed Jul 8, 2020
1 parent 80403f0 commit 6f2d901
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ composer require izica/laravel-backpack-relations-widgets
* `button_show` (optional) - set false to hide
* `button_edit` (optional) - set false to hide
* `visible` (optional) - closure for hiding or showing panel
* `fields` - fields array,
* `fields` (optional) - fields array, by default get columns from `fillable` in model
* `name` - name
* `label` - for field
* `closure` - use closure instead of name field,
Expand All @@ -46,7 +46,7 @@ composer require izica/laravel-backpack-relations-widgets
* `button_edit` (optional) - set false to hide
* `button_delete` (optional) - set false to hide
* `visible` (optional) - closure for hiding or showing panel
* `columns` - fields array,
* `fields` (optional) - columns array, by default get columns from `fillable` in model
* `name` - name
* `label` - for field
* `closure` - use closure instead of name field,
Expand Down
File renamed without changes.
6 changes: 5 additions & 1 deletion src/resources/views/widgets/relation_panel.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
}
}
if(!isset($widget['fields'])){
$widget['fields'] = [];
foreach ($entry->{$widget['name']}->getFillable() as $propertyName){
$widget['fields'][$propertyName] = $crud->makeLabel($propertyName);
$widget['fields'][] = [
'label' => $crud->makeLabel($propertyName),
'name' => $propertyName,
];
}
}
Expand Down
11 changes: 7 additions & 4 deletions src/resources/views/widgets/relation_table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
if (!isset($widget['button_delete']) || $widget['button_delete'] !== false) {
$widget['button_delete'] = true;
}
if(!isset($widget['columns']) && isset($widget['model'])){
$model = new $widget['model']();
foreach ($model->getFillable() as $propertyName){
$widget['columns'][$propertyName] = $crud->makeLabel($propertyName);
if(!isset($widget['columns'])){
$widget['columns'] = [];
foreach ($entry->{$widget['name']}->getFillable() as $propertyName){
$widget['columns'][] = [
'label' => $crud->makeLabel($propertyName),
'name' => $propertyName,
];
}
}
if(!isset($widget['columns']) && !isset($widget['model'])){
Expand Down

0 comments on commit 6f2d901

Please sign in to comment.