PHP code example of vinlon / laravel-lay-admin

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

    

vinlon / laravel-lay-admin example snippets


class AdminRoleExtend extends AdminRole
{
    const TEST = '新角色测试';

    /**
     * @return string[]
     */
    public function getMenuIds()
    {
        $roleMenus = [
            self::TEST => ['_my.profile', 'ops.setting', '_user'],
        ];

        return Arr::get($roleMenus, $this->value, []);
    }

    /**
     * @return string[]
     */
    public function getPrivileges()
    {
        $rolePrivileges = [
            self::TEST => [1, 2, 3],
        ];

        return Arr::get($rolePrivileges, $this->value, []);
    }
}

shell
php artisan vendor:publish --provider="Vinlon\Laravel\LayAdmin\LayAdminServiceProvider" --tag=public --force
shell
php artisan vendor:publish --provider="Vinlon\Laravel\LayAdmin\LayAdminServiceProvider" --tag=config
shell
php artisan jwt:secret

php artisan lay-admin:reset-password admin admin

Route::group(['middleware' => ['auth:lay-admin']], function () {
    //这里放置你的需要登录Admin后台API路由
});