PHP code example of chencongbao / laravel-vben-admin

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

    

chencongbao / laravel-vben-admin example snippets


Route::post('/api/admin/matches/{match}/publish', PublishMatchController::class)
    ->middleware(['auth:sanctum', 'admin.user', 'admin.permission:match.publish']);

use Chencongbao\LaravelVbenAdmin\Contracts\AdminModule;
use Chencongbao\LaravelVbenAdmin\Contracts\ModuleRegistry;
use Chencongbao\LaravelVbenAdmin\Definitions\MenuDefinition;
use Chencongbao\LaravelVbenAdmin\Definitions\PermissionDefinition;

final class MatchAdminModule implements AdminModule
{
    public function key(): string
    {
        return 'matches';
    }

    public function permissions(): array
    {
        return [
            new PermissionDefinition('match.view', 'View matches'),
            new PermissionDefinition('match.publish', 'Publish matches', sensitive: true),
        ];
    }

    public function menus(): array
    {
        return [
            new MenuDefinition(
                code: 'match.list',
                title: 'Matches',
                type: 'page',
                routeName: 'MatchList',
                routePath: '/matches',
                viewKey: 'match.list',
                permissionCode: 'match.view',
            ),
        ];
    }
}

app(ModuleRegistry::class)->register(new MatchAdminModule());
bash
cd frontend
VITE_BASE=/control-center/ pnpm build:antd
cd ..
php artisan vben-admin:publish-assets
bash
php artisan vben-admin:publish-workspace
text
cmsadmin / admin (super administrator)
admin / admin (manager)
bash
php artisan vben-admin:sync --dry-run
php artisan vben-admin:sync