PHP code example of crumbls / filament-database

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

    

crumbls / filament-database example snippets


use Crumbls\FilamentDatabase\FilamentDatabasePlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        // ...
        ->plugins([
            FilamentDatabasePlugin::make()
                ->authorize(function() { 
                    // You need to customize this. It controls who can view it.
                    return false; 
                }),
        ]);
}

FilamentDatabasePlugin::make()
    // Access control
    ->authorize(fn () => auth()->user()->is_admin)
    ->onlyForEmails(['[email protected]'])

    // Connections
    ->connections(['mysql', 'sqlite'])
    ->excludeConnections(['pgsql'])
    ->defaultConnection('mysql')

    // Safety
    ->readOnly()
    ->preventDestructive()
    ->se')
    ->rowsPerPage(25)
    ->maxRowsPerPage(500)

    // Audit
    ->logQueries()
    ->logChanges()

// Closure — full control
FilamentDatabasePlugin::make()
    ->authorize(fn () => auth()->user()->is_admin)

// Laravel Gate
FilamentDatabasePlugin::make()
    ->authorizeUsing('manage-database')

// Email allowlist
FilamentDatabasePlugin::make()
    ->onlyForEmails(['[email protected]'])

FilamentDatabasePlugin::make()
    ->authorize(fn () => auth()->user()->is_admin)
    ->readOnly()                          // block all writes
    ->preventDestructive()                // block DROP / TRUNCATE
    ->connections(['mysql'])              // limit to specific connections
    ->logQueries()                        // audit all SQL
    ->logChanges()                        // audit all data changes
bash
php artisan vendor:publish --tag=filament-database-config