1. Go to this page and download the library: Download riodwanto/filament-logger 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/ */
riodwanto / filament-logger example snippets
namespace App\Providers;
use Filament\Panel;
use Filament\PanelProvider;
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->resources([
config('filament-logger.activity_resource')
]);
}
}
namespace App\Loggers;
use Riodwanto\FilamentLogger\Loggers\AbstractModelLogger;
class PaymentLogger extends AbstractModelLogger
{
protected function getLogName(): string
{
return 'Payment';
}
public function paymentProcessed($payment)
{
$this->log($payment, 'Processed', 'Payment was processed successfully');
}
}
// In your config
'navigation_group' => 'Audit',
'navigation_sort' => 10,
'scoped_to_tenant' => false, // Set to false for global logs
'datetime_format' => 'Y-m-d H:i:s', // Database format
'date_format' => 'Y-m-d', // Display format
use Filament\Tables\Actions\BulkAction;
// In your ActivityResource table method
BulkAction::make('export')
->label('Export Selected')
->icon('heroicon-o-download')
->action(function ($records) {
// Your export logic here
}),
// In your config/filament-logger.php
'debug' => env('FILAMENT_LOGGER_DEBUG', false),
namespace App\Providers;
use App\Policies\ActivityPolicy;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Spatie\Activitylog\Models\Activity;
class AuthServiceProvider extends ServiceProvider
{
protected $policies = [
// Update `Activity::class` with the one defined in `config/activitylog.php`
Activity::class => ActivityPolicy::class,
];
//...
}