PHP code example of allyson / admin-tools-library

1. Go to this page and download the library: Download allyson/admin-tools-library 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/ */

    

allyson / admin-tools-library example snippets



namespace App\Providers;

use AdminToolsLibrary\Registry\Tool;
use AdminToolsLibrary\Contracts\ToolProvider;
use AdminToolsLibrary\Registry\ToolRegistry;

class AdminToolsBootstrapProvider implements ToolProvider
{
    public function tools(): array
    {
        return [
            Tool::make([
                'id' => 'telescope',
                'name' => 'Telescope',
                'description' => '🔭 Monitore requests & queries',
                'icon' => '🔭',
                'url' => '/telescope',
                'enabled' => true,
                'package' => 'laravel/telescope',
            ]),
        ];
    }

    public function registerTools(ToolRegistry $registry): void
    {
        foreach ($this->tools() as $tool) {
            $registry->register($tool);
        }
    }
}

// config/admin-tools.php
return [
    'tools' => [
        App\Providers\AdminToolsBootstrapProvider::class,
    ],
];

$registry = app(ToolRegistry::class);
$registry->register($tool);
$registry->all();                    // Todas as ferramentas
$registry->all()->enabled();         // Apenas habilitadas
$registry->all()->byPackage('tele'); // Por package

interface ToolProvider {
    public function tools(): array;
    public function registerTools(ToolRegistry $registry): void;
}