yeknava/simple-admin

laravel 的简单管理包

0.6 2020-04-21 01:00 UTC

This package is auto-updated.

Last update: 2024-09-21 21:24:43 UTC


README

Laravel Simple Admin Package 允许您为应用程序创建一个简单的管理面板。所有内容都在配置文件中定义,并且可以通过在模型类中覆盖方法进行自定义。

安装

使用包管理器 composer 安装简单管理包。

composer require yeknava/simple-admin

使用方法

在终端运行此命令

php artisan vendor:publish

配置

<?php

use Yeknava\SimpleAdmin\SimpleAdminBasicMiddleware;

return [
    /*
     * route's base path that will be used for package specific routes.
     * (use 'php artisan route:list' to find out all paths)
     */
    'route_base_path' => '/simple-admin',

    /*
     * middlewares that admin needs to pass before access to panel.
     * if you don't have any login process that admin may to use it to login first,
     * SimpleAdminBasicMiddleware will provide basics auth functionality. 
     */
    'middlewares' => [SimpleAdminBasicMiddleware::class, 'throttle:10,1'],

    /*
     * if you are using SimpleAdminBasicMiddleware middleware and you set
     * use_login_method config to false, you need to provide default
     * username and password to login. 
     */
    'default_username' => env('SA_USERNAME', 'username'),
    'default_password' => env('SA_PASSWORD', 'secret'),

    /*
     * if you need to use login_method option set this true
     */
    'use_login_method' => false,

    /*
     * you may check username and password with database here, return true
     * if username and password fields are match with user.
     */
    'login_method' => function(string $username, string $password) : bool {
        return true;
    },

    /*
     * admin panel pages:
     */
    'pages' => [
        'users' => [
            'path' => '/users',
            'title' => 'Users',
            'create' => true,
            'edit' => true,
            'delete' => true,
            'view' => null,
            
            /*
             * content is model class, if you need customize any fields or
             * process you need to use SimpleAdminTrait in your model class
             */
            'content' => \App\User::class,
        ],
    ]
];

贡献

欢迎提交拉取请求。对于重大更改,请先提交一个问题以讨论您希望进行哪些更改。

许可证

MIT