black-paradise/laravel-admin 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

black-paradise/laravel-admin

Composer 安装命令:

composer require black-paradise/laravel-admin

包简介

Laravel adapter for BPAdmin — config-driven CRUD admin panel (v3)

README 文档

README

Laravel 11/12/13 adapter for BPAdmin v3. Provides Eloquent repository/mutator, CRUD controllers, service provider, and route wiring. Requires bp-admin-core (pure PHP domain layer).

Installation

composer require black-paradise/laravel-admin

Publish the config:

php artisan vendor:publish --tag=bpadmin-config

Scaffold entity definition stubs:

php artisan bpadmin:install

Configuration

All options live in config/bpadmin.php. Key keys:

Key Default Description
prefix 'admin' URL prefix for all admin routes
middleware ['web'] Middleware applied to all admin routes
guard 'web' Laravel auth guard
storage_disk 'public' Filesystem disk for file uploads
per_page 15 Default pagination size

Middleware & CSRF

BPAdmin routes use config('bpadmin.middleware', ['web']). The default web middleware group includes VerifyCsrfToken. If you override bpadmin.middleware, preserve VerifyCsrfToken — using only api will silently strip CSRF protection from every admin form (login, create, update, delete).

To add custom middleware while keeping CSRF, append rather than replace: config(['bpadmin.middleware' => ['web', 'auth.custom']]).

Entity Definitions

Create App\BPAdmin\{Name} classes extending EntityDefinition:

use BlackParadise\CoreAdmin\EntityDefinition;
use BlackParadise\CoreAdmin\Domain\Fields\TextField;
use BlackParadise\CoreAdmin\Domain\Fields\BooleanField;

class Users extends EntityDefinition
{
    public string $model = \App\Models\User::class;

    public function fields(): array
    {
        return [
            TextField::make('name')->required()->searchable(),
            TextField::make('email')->required(),
            BooleanField::make('is_active'),
        ];
    }
}

DashboardServiceProvider auto-discovers all EntityDefinition subclasses in app/BPAdmin/ at boot.

Production Deployment

During a production deploy, cache entity definitions alongside Laravel's own caches:

php artisan config:cache
php artisan route:cache
php artisan bpadmin:cache   # pre-builds entity manifest → bootstrap/cache/bpadmin-entities.php

Without bpadmin:cache, every request walks the filesystem to discover entity classes. This is fine locally, but in production it adds measurable overhead and triggers a boot-time log warning to remind you to run the cache command.

To clear the entity manifest (e.g. during rollback or after removing an entity):

php artisan bpadmin:cache --clear

License

MIT

统计信息

  • 总下载量: 73
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-09-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固