PHP code example of mahmoud-mhamed / laravel-dblens

1. Go to this page and download the library: Download mahmoud-mhamed/laravel-dblens 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/ */

    

mahmoud-mhamed / laravel-dblens example snippets


Route::middleware([
    \Stancl\Tenancy\Middleware\InitializeTenancyByDomain::class,
    \Stancl\Tenancy\Middleware\PreventAccessFromCentralDomains::class,
])->group(function () {
    // DbLens auto-registers under /dblens for any group it's mounted in.
    // No code needed — the package's service provider already loaded its
    // routes against the current route() context.
});

return [
    // Environment switches
    'enable_local' => true,
    'enable_production' => false,           // turn on with caution
    'read_only' => env('DBLENS_READONLY', false),

    // URL + access
    'viewer' => [
        'enabled' => true,
        'path' => env('DBLENS_PATH', 'dblens'),
        'domain' => env('DBLENS_DOMAIN'),
        'middleware' => ['web', 'auth'],        //                     // empty = allow all from config/database.php
        'default' => env('DBLENS_DEFAULT_CONNECTION', env('DB_CONNECTION', 'mysql')),
    ],

    // SQL editor
    'sql_editor' => [
        'enabled' => true,
        'allow_writes' => env('DBLENS_SQL_WRITES', false),
        'max_rows' => 1000,
        'timeout_seconds' => 30,
    ],

    // Browse
    'browse' => [
        'per_page' => 30,
        'per_page_options' => [10, 30, 50, 100, 200],
        'truncate_cell' => 120,
    ],

    // Mask values for these column names (case-insensitive)
    'masked_columns' => [
        'password', 'remember_token', 'api_token', 'secret',
    ],

    // Require a `confirm=1` request flag for destructive operations
    'confirm_destructive' => true,
];

// config/dblens.php  (default)
'viewer' => [
    'middleware' => ['web', 'auth'],
],

'middleware' => ['web', 'auth:admin'],              // a guard called 'admin'
'middleware' => ['web', 'auth', 'can:access-admin'], // chain a permission
'middleware' => ['web'],                             // open dashboard (rely on password / Gate below)

use Illuminate\Support\Facades\Gate;

Gate::define('viewDbLens', function ($user) {
    return $user?->is_admin === true;
});
bash
php artisan dblens:install
bash
php artisan dblens:install --force
bash
php artisan vendor:publish --tag=dblens-config
bash
php artisan vendor:publish --tag=dblens-views
bash
php artisan vendor:publish --tag=dblens-config --force
php artisan vendor:publish --tag=dblens-views  --force
bash
php artisan config:clear
# or
php artisan config:cache
bash
php artisan tinker
>>> echo Hash::make('your-secret-password');