You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To conditionally customize datetime columns in the UI, depending on the user's calendar preference:
349
+
350
+
```php
351
+
use Rmsramos\Activitylog\ActivitylogPlugin;
352
+
353
+
public function panel(Panel $panel): Panel
354
+
{
355
+
return $panel
356
+
->plugins([
357
+
ActivitylogPlugin::make()
358
+
->customizeDatetimeColumn(function ($column) {
359
+
return $column->when(
360
+
auth()->user()->isJalaliCalendar(),
361
+
function ($column) {
362
+
return $column->jalaliDateTime();
363
+
}
364
+
);
365
+
})
366
+
]);
367
+
}
368
+
```
369
+
370
+
## Customize Date Picker Fields
371
+
372
+
To customize date picker fields in forms, depending on user preferences:
373
+
374
+
```php
375
+
use Rmsramos\Activitylog\ActivitylogPlugin;
376
+
377
+
public function panel(Panel $panel): Panel
378
+
{
379
+
return $panel
380
+
->plugins([
381
+
ActivitylogPlugin::make()
382
+
->customizeDatePicker(function ($field) {
383
+
return $field->when(
384
+
auth()->user()->isJalaliCalendar(),
385
+
function ($field) {
386
+
return $field->jalali();
387
+
}
388
+
);
389
+
})
390
+
]);
391
+
}
392
+
```
393
+
394
+
## Manipulate View Action Using Custom Activity Resource Trait
395
+
396
+
Implement `getFilamentActualResourceModel` in the trait `HasCustomActivityResource` to determine the actual model related to the activity record for generating valid URLs.
397
+
398
+
```php
399
+
use Rmsramos\Activitylog\Traits\HasCustomActivityResource;
400
+
401
+
trait HasCustomActivityResource
402
+
{
403
+
public function getFilamentActualResourceModel($record)
404
+
{
405
+
$record = $record->subject->translatable;
406
+
$model = null;
407
+
408
+
switch ($record::class) {
409
+
case FirstTranslatableModel::class:
410
+
$model = $record->firstModel;
411
+
break;
412
+
413
+
case SecondTranslatableModel::class:
414
+
$model = $record->secondModel;
415
+
break;
416
+
417
+
default:
418
+
throw new Exception("Error Translatable subject model not found. record = ".$record::class, 1);
419
+
break;
420
+
}
421
+
422
+
return $model;
423
+
}
424
+
}
425
+
```
426
+
427
+
### Hide Restore / View Action
428
+
429
+
To hide the restore / view action globally for a resource within the `ActivitylogPlugin`, you can use the `isRestoreActionHidden` and `isResourceActionHidden` method. these are particularly useful in scenarios where you do not want users to have the ability to restore or view entries from the activity log. you can also customize the label of view action:
430
+
431
+
```php
432
+
use Rmsramos\Activitylog\ActivitylogPlugin;
433
+
434
+
public function panel(Panel $panel): Panel
435
+
{
436
+
return $panel
437
+
->plugins([
438
+
ActivitylogPlugin::make()
439
+
->isRestoreActionHidden(true)
440
+
->isResourceActionHidden(true)
441
+
->resourceActionLabel("Sample Label")
442
+
]);
443
+
}
444
+
```
445
+
446
+
282
447
### Role Policy
283
448
284
449
To ensure ActivitylogResource access via RolePolicy you would need to add the following to your AppServiceProvider:
@@ -317,7 +482,35 @@ public function panel(Panel $panel): Panel
"created_by_at" => "The <strong>:subject</strong> was <strong>:event</strong> by <strong>:causer</strong>. <br><small> Updated at: <strong>:update_at</strong></small>",
6
+
"updater_updated" => ":causer :event the following: <br>:changes",
7
+
"from_oldvalue_to_newvalue" => "- :key from <strong>:old_value</strong> to <strong>:new_value</strong>",
0 commit comments