PHP code example of onelearningcommunity / laravel-model-explorer

1. Go to this page and download the library: Download onelearningcommunity/laravel-model-explorer 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/ */

    

onelearningcommunity / laravel-model-explorer example snippets


Gate::define('viewModelExplorer', function (User $user): bool {
    return $user->isAdmin();
});

return [
    // Set to false to disable entirely (e.g. force off in production regardless of gate)
    'enabled' => env('MODEL_EXPLORER_ENABLED', true),

    // URL prefix for all Model Explorer routes
    'path' => env('MODEL_EXPLORER_PATH', '_model-explorer'),

    // Middleware applied to all routes ('web' is ,
    ],

    // Model classes matching these patterns are hidden, even inside a scanned path.
    // Entries match the FQCN and may use `*` as a wildcard (leading `\` is ignored).
    'excluded_models' => [
        // 'Laravel\\Telescope\\*',
        // 'App\\Models\\Internal\\AuditLog',
    ],

    // Traits whose FQN begins with these prefixes will be hidden in the UI
    'excluded_trait_prefixes' => [
        'Illuminate\Database\Eloquent\Concerns\\',
        'Illuminate\Database\Eloquent\HasCollection',
        'Illuminate\Support\Traits\\',
    ],

    // Related records shown per page when drilling into a to-many relation,
    // and the cap on collection-returning accessor values.
    'per_page' => env('MODEL_EXPLORER_PER_PAGE', 15),

    // Cache model discovery and inspection results (recommended for large apps).
    // Disabled by default so model changes appear immediately during development.
    'cache' => [
        'enabled' => env('MODEL_EXPLORER_CACHE', false),
        'store'   => env('MODEL_EXPLORER_CACHE_STORE'),   // null = default store
        'ttl'     => env('MODEL_EXPLORER_CACHE_TTL'),     // seconds; null = forever
    ],
];
bash
php artisan vendor:publish --tag="model-explorer-config"
bash
php artisan model-explorer:clear