PHP code example of asignua / filament-activity-log-plus
1. Go to this page and download the library: Download asignua/filament-activity-log-plus library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
asignua / filament-activity-log-plus example snippets
use Asignua\FilamentActivityLogPlus\Concerns\LogsActivityPlus;
class Post extends Model
{
use LogsActivityPlus; // instead of spatie's LogsActivity, which it
protected function activityExcept(): array { return ['api_secret']; } // your own secrets
protected function activityTranslatableAttributes(): array { return ['title']; } // see below
protected function activityIgnoreOnlyChanged(): array { return ['path']; } // derived columns
protected function activityTranslatableAttributes(): array
{
return ['title', 'summary'];
}
app(ActivityBatch::class)->run(function () use ($post): void {
$post->update([...]);
$post->syncAndLog('tags', $ids);
});
use Asignua\FilamentActivityLogPlus\Concerns\LogsPivotSync;
class Post extends Model
{
use LogsActivityPlus;
use LogsPivotSync;
}
$post->syncAndLog('tags', [1, 2, 3]); // returns sync()'s result
// or, for anything else (attach/detach, a custom pivot):
PivotSynced::dispatch($post, 'tags', attached: [3], detached: [1]);
ActivityEvents::register(
'approved',
'Approved', // a translation key or a ready string, or a closure
color: 'success', // a Filament colour
summary: fn (Activity $a): string => (string) $a->getProperty('note'),
view: 'my-app::activity.approved', // optional: replaces the body of the card
);
use Asignua\FilamentActivityLogPlus\Actions\ActivityHistoryAction;
protected function getHeaderActions(): array
{
return [ActivityHistoryAction::make(), DeleteAction::make()];
}
ActivityLogPlusPlugin::make()
->navigationGroup('System')
->navigationSort(8)
->navigationIcon('heroicon-o-clipboard-document-list')
->resource(false); // History action only
ActivityLogPlusPlugin::make()
->authorizeResource(fn (): bool => auth()->user()?->isAdmin()) // the log resource
->authorizeHistory(fn (): bool => true); // the History action