PHP code example of gboquizosanchez / filament-log-viewer

1. Go to this page and download the library: Download gboquizosanchez/filament-log-viewer 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/ */

    

gboquizosanchez / filament-log-viewer example snippets


->plugin(\Boquizo\FilamentLogViewer\FilamentLogViewerPlugin::make())

->plugins([
    \Boquizo\FilamentLogViewer\FilamentLogViewerPlugin::make()
        ->navigationGroup('System')
        ->navigationSort(2)
        ->navigationIcon('heroicon-s-document-text')
        ->navigationLabel('Log Viewer')
        ->authorize(fn() => auth()->user()->can('view-logs')),
    // Other plugins
])

// app/Filament/Pages/CustomListLogs.php


namespace App\Filament\Pages;

use Boquizo\FilamentLogViewer\Pages\ListLogs as BaseListLogs;
use Filament\Tables\Table;

class CustomListLogs extends BaseListLogs
{
    protected static ?string $navigationLabel = 'Application Logs';
    
    protected static ?string $navigationGroup = 'Monitoring';
    
    public function table(Table $table): Table
    {
        return parent::table($table)
            ->defaultPaginationPageOption(25)
            ->poll('30s'); // Auto-refresh every 30 seconds
    }
}

// app/Filament/Pages/CustomViewLog.php


namespace App\Filament\Pages;

use Boquizo\FilamentLogViewer\Pages\ViewLog as BaseViewLog;
use Filament\Actions\Action;

class CustomViewLog extends BaseViewLog
{
    protected function getHeaderActions(): array
    {
        return array_merge(parent::getHeaderActions(), [
            Action::make('export')
                ->label('Export to CSV')
                ->icon('heroicon-o-arrow-down-tray')
                ->action(fn() => $this->exportToCsv()),
        ]);
    }
    
    private function exportToCsv(): void
    {
        // Custom export logic
    }
}

->plugins([
    \Boquizo\FilamentLogViewer\FilamentLogViewerPlugin::make()
        ->listLogs(\App\Filament\Pages\CustomListLogs::class)
        ->viewLog(\App\Filament\Pages\CustomViewLog::class)
        ->navigationGroup('System')
        ->navigationSort(2)
        ->navigationIcon('heroicon-s-document-text')
        ->navigationLabel('System Logs')
        ->authorize(function () {
            return auth()->user()->hasAnyRole(['admin', 'developer']);
        }),
    // Other plugins like FilamentEmailPlugin, etc.
])
shell
php artisan vendor:publish --provider="Boquizo\FilamentLogViewer\FilamentLogViewerServiceProvider"