Fields


In the context of the Logger class, you have the flexibility to define which fields and relations should be logged for your model. This allows you to track changes to specific attributes and related data.

Badge

1
2
3
4
$logger->fields([
   'name' => 'badge:danger',
   // Field::make('name')->badge('danger'),
])

Screenshot


Enum

1
2
3
4
5
$logger->fields([
   Field::make('status')
         ->enum(App\Enums\OrderStatus::class)
         ->label('Status'),
])

Screenshot


Date & Time

1
2
3
4
5
6
7
8
$logger->fields([
   // 'published_at' => 'date:j F, Y'',
   // 'published_at' => 'time',
   // 'published_at' => 'datetime',
   Field::make('published_at')
         ->date()
         ->label('Publish Date'),
])

Screenshot


Boolean

1
2
3
4
5
6
$logger->fields([
   // 'is_visible' => 'boolean',
   Field::make('is_visible')
         ->boolean()
         ->label('Visible'),
])

Screenshot


Media

1
2
3
4
5
6
$logger->fields([
   // 'media' => 'media',
   Field::make('media')
         ->media(gallery: true)
         ->label('Images'),
])

Screenshot


Money

1
2
3
4
$logger->fields([
   // 'price' => 'money:EUR',
   Field::make('price')->money('EUR'),
])

Screenshot


Key-Value

1
2
3
4
5
$logger->fields([
   Field::make('meta')
         ->keyValue(differenceOnly: true)
         ->label('Attributes'),
])

#### Key-Value with fields

1
2
3
4
5
6
7
8
9
$logger->fields([
   Field::make('recipient')
         ->hasOne('recipient')
         ->keyValue([
            Field::make('recipient.full_name'),
            Field::make('recipient.phone'),
            Field::make('recipient.shipping_provider'),
         ]),
])

Screenshot


Relation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$logger->fields([
   Field::make('roles.name')
         ->hasMany('roles')
         ->label(__('Roles'))
         ->badge(),

   Field::make('permissions.name')
         ->hasMany('permissions')
         ->label(__('Permissions'))
         ->badge(),

   Field::make('status.name')
         ->hasOne('status')
         ->label(__('Status'))
         ->badge(),
])

Screenshot


Table

1
2
3
4
5
6
7
8
9
10
11
12
$logger
   ->preloadRelations('items.product')
   ->fields([
      Field::make('items')
            ->hasMany('items')
            ->table([
                Field::make('product.name')->hasOne('product'),
                Field::make('qty'),
                Field::make('unit_price'),
            ])
            ->label('Items'),
        ]),

Screenshot


Difference

1
2
3
4
$logger->fields([
   Field::make('description')
         ->difference(),
])

For now, it is compatible with text only.

Screenshot


Inline

1
2
3
4
5
$logger->fields([
   Field::make('active')
         ->boolean()
         ->inline(), // <----- here
])

Change is displayed inside the header. Only works if only one field has been changed.

Screenshot


Table of contents