PHP code example of mano-code / custom-extend

1. Go to this page and download the library: Download mano-code/custom-extend 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/ */

    

mano-code / custom-extend example snippets




namespace ManoCode\Demo;

use ManoCode\CustomExtend\Extend\ManoCodeServiceProvider;

/**
 * 扩展的服务提供者
 */
class DemoServiceProvider extends ManoCodeServiceProvider
{
    protected $menu = [
        [
            'parent' => '',
            'title' => '演示系统',
            'url' => '/demo',
            'url_type' => '1',
            'icon' => 'ant-design:file-zip-outlined',
        ]
    ];
    protected $dict = [
        [
            'key' => 'filesystem.driver',
            'value' => '文件系统驱动',
            'keys' => [
                [
                    'key' => 'local',
                    'value' => '本地存储'
                ],
                [
                    'key' => 'kodo',
                    'value' => '七牛云kodo'
                ],
                [
                    'key' => 'cos',
                    'value' => '腾讯云COS'
                ],
                [
                    'key' => 'oss',
                    'value' => '阿里云OSS'
                ]
            ]
        ]
    ];
    protected $permission = [
        [
            'name'=>'测试权限',
            'slug'=>'test',
            'method'=>[],// 空则代表ANY
            'path'=>[],// 授权接口
            'parent'=>'',// 父级权限slug字段
        ],
        [
            'name'=>'测试接口',
            'slug'=>'test',
            'method'=>[
                'POST',
                'GET',
            ],// 空则代表ANY
            'path'=>[
                '/test/api*'
            ],// 授权接口
            'parent'=>'test',// 父级权限slug字段
        ],
    ];
}



use Illuminate\Support\Facades\Route;
Route::any('/demo',function(){
    return ['msg'=>'HelloWorld'];
});
Route::get('/test',[ManoCode\FileSystem\Http\Controllers\DemoApiController::class,'test']);
Route::get('/test1',[ManoCode\FileSystem\Http\Controllers\DemoApiController::class,'test1']);



namespace ManoCode\FileSystem\Http\Controllers;

use Illuminate\Routing\Controller;
use ManoCode\CustomExtend\Traits\ApiResponseTrait;

/**
 *
 */
class DemoApiController extends Controller
{
    use ApiResponseTrait;
    public function test()
    {
        return $this->success('测试成功',[
            'list'=>[]
        ]);
    }
    public function test1()
    {
        return $this->fail('错误',[
            'list'=>[]
        ]);
    }
}

/**
 * 检查当前管理员用户 是否属于指定的角色
 * @param string|array $role
 * @return bool
 */
function admin_user_role_check(string|array $role):bool;
// 使用示例
admin_user_role_check('Administrator');// 检查是否是 超级管理员
admin_user_role_check(['Administrator','user-passs']);// 检查是否是 超级管理员 并且是 用户审核员
bash
php artisan publish:docker