Skip to content

Commit

Permalink
Update ActivityResource.php (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
Z3d0X authored Dec 22, 2022
1 parent f854f14 commit 20df88b
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions src/Resources/ActivityResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,34 @@ public static function form(Form $form): Form
}),
])
]),
Card::make([
KeyValue::make('properties')
->visible(fn ($livewire) => !isset($livewire->data['properties']['attributes']))
->label(__('filament-logger::filament-logger.resource.label.properties'))
->columnSpan('full'),
Card::make()
->columns()
->visible(fn ($record) => $record->properties?->count() > 0)
->schema(function (?Activity $record) {
$properties = $record->properties->except(['attributes', 'old']);

$schema = [];

if ($properties->count()) {
$schema[] = KeyValue::make('properties')
->label(__('filament-logger::filament-logger.resource.label.properties'))
->columnSpan('full');
}

KeyValue::make('properties.old')
->visible(fn ($livewire) => isset($livewire->data['properties']['old']))
->label(__('filament-logger::filament-logger.resource.label.old')),
if ($old = $record->properties->get('old')) {
$schema[] = KeyValue::make('old')
->afterStateHydrated(fn (KeyValue $component) => $component->state($old))
->label(__('filament-logger::filament-logger.resource.label.old'));
}

KeyValue::make('properties.attributes')
->visible(fn ($livewire) => isset($livewire->data['properties']['attributes']))
->label(__('filament-logger::filament-logger.resource.label.new')),
if ($attributes = $record->properties->get('attributes')) {
$schema[] = KeyValue::make('attributes')
->afterStateHydrated(fn (KeyValue $component) => $component->state($attributes))
->label(__('filament-logger::filament-logger.resource.label.new'));
}

])->columns(2)->visible(fn ($record) => $record->properties?->count() > 0)
return $schema;
}),
])
->columns(['sm' => 4, 'lg' => null]);
}
Expand Down

0 comments on commit 20df88b

Please sign in to comment.