jzpeepz / dynamo
快速为您的现有 Laravel 应用程序构建管理员,使用真实数据库表
Requires
- doctrine/dbal: ^2.10
- illuminate/support: ^6.0|^7.0|^8.0
- laravelcollective/html: ^6.0
- dev-master
- 1.4.28
- 1.4.27
- 1.4.26
- 1.4.25
- 1.4.24
- 1.4.23
- 1.4.22
- 1.4.21
- 1.4.20
- 1.4.18
- 1.4.17
- 1.4.16
- 1.4.15
- 1.4.14
- 1.4.13
- 1.4.12
- 1.4.11
- 1.4.10
- 1.4.9
- 1.4.8
- 1.4.7
- 1.4.6
- 1.4.5
- 1.4.4
- 1.4.2
- 1.4.1
- 1.4.0
- v1.3.x-dev
- 1.3.50
- 1.3.49
- 1.3.48
- 1.3.47
- 1.3.46
- 1.3.45
- 1.3.44
- 1.3.43
- 1.3.42
- 1.3.41
- 1.3.40
- 1.3.39
- 1.3.35
- 1.3.34
- 1.3.33
- 1.3.32
- 1.3.31
- 1.3.30
- 1.3.29
- 1.3.28
- 1.3.27
- 1.3.26
- 1.3.25
- 1.3.24
- 1.3.23
- 1.3.22
- 1.3.21
- 1.3.20
- 1.3.19
- 1.3.18
- 1.3.17
- 1.3.16
- 1.3.15
- 1.3.14
- 1.3.13
- 1.3.12
- 1.3.11
- 1.3.10
- 1.3.9
- 1.3.8
- 1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.25
- 1.2.24
- 1.2.23
- 1.2.22
- 1.2.21
- 1.2.20
- 1.2.19
- 1.2.18
- 1.2.17
- 1.2.16
- 1.2.15
- 1.2.14
- 1.2.13
- 1.2.12
- 1.2.11
- 1.2.10
- 1.2.9
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2
- v1.1.x-dev
- 1.1.15
- 1.1.14
- 1.1.13
- 1.1.12
- 1.1.11
- 1.1.10
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1
- 1.0.28
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-dependabot/composer/symfony/mime-4.4.1
- dev-dependabot/composer/symfony/http-foundation-4.4.1
- dev-BOOTSTRAP4
- dev-soft-deletes-fix
- dev-categories-feature
- dev-character-counter-feature
- dev-adding_realtionships_between_models
This package is auto-updated.
Last update: 2024-09-11 02:11:09 UTC
README
通过 Composer 安装
composer require jzpeepz/dynamo
在您的 config/app.php
文件中包含服务提供者
Jzpeepz\Dynamo\DynamoServiceProvider::class
发布 Dynamo 配置文件
php artisan vendor:publish --tag=dynamo
注意:如果使用本地磁盘上传,请确保将其符号链接到您的公共目录,并在配置文件中提供正确的路径。
配置
storage_disk
用于存储上传文件的存储磁盘。默认:'local'
upload_path
存储磁盘内的路径,用于存储上传的文件。这也是公共目录中链接到的存储目录所在的目录。默认:'/uploads/'
route_prefix
添加到所有 Dynamo 路由的前缀。默认:'' (空字符串)
layout
与 Dynamo 视图一起使用的布局。默认:'layouts.app'
controller_namespace
生成控制器的命名空间。默认:'App\Http\Controllers'
controller_path
存储生成控制器的路径。默认:app_path('/Http/Controllers')
view_prefix
覆盖视图的前缀。默认:'dynamo'
view_theme
视图使用的主题。默认:'bootstrap4'
target_blade_section
模板中渲染视图的 blade 部分。默认:'content'
default_has_many_class
默认用于 hasMany 字段类型的 CSS 类。默认:''
model_uses
此值包含应导入到生成模型类中的类数组。默认:[]
model_implements
此值包含应由生成模型类实现的接口数组。默认:[]
model_traits
此值包含应用于生成模型类的特性数组。默认:[]
用法
生成您的第一个管理员
以下命令将为您创建管理员控制器、模型、迁移和路由
php artisan make:dynamo Employee
需要放弃 Dynamo 的一些魔法吗?
php artisan make:dynamo Employee --migration=no --model=no --controller=no --route=no
自定义管理员
管理员自定义发生在控制器中的 getDynamo()
函数内部。此函数返回一个 Dynamo 实例,该实例具有许多可链式方法,可以自定义您的 Dynamo 管理员。以下是可以链式调用的方法。
自定义索引
默认情况下,Dynamo 会将数据库表中的所有字段添加到索引中。在生成的控制器中 getDynamo()
方法中删除对 auto()
的调用将停止将所有字段添加到索引和表单中。
添加索引列
addIndex($key, $label = null, $formatCallable = null)
此方法允许您添加或更新索引列。
参数
$key
如果您希望用表数据填充它,这是您的数据库表中的列名。否则,它可以是任何唯一的名称。
$label
(可选)这是您希望人们看到的漂亮名称。
$formatCallable
(可选)这是一个闭包,允许您完全自定义索引列的渲染方式。此闭包将接收一个参数,即该行的 Eloquent 实例。闭包应返回您想在索引列中渲染的内容。
删除索引列
removeIndex($key)
此方法允许您从索引中删除列。
参数
$key
这是创建索引时使用的键。通常它是数据库表中的列名。
删除所有索引列
clearIndexes()
此方法移除所有索引列。这可以用来清除由 auto()
创建的索引,同时保留表单字段。
排序索引行
indexOrderBy($column, $sort = 'asc')
此方法允许您对从数据库返回的行进行排序。
分页索引行
paginate($limit)
此方法允许您设置索引每页显示的行数。
在索引中创建标签页
将搜索添加到索引
将过滤器添加到索引
隐藏每行的删除按钮
隐藏添加按钮
将按钮添加到索引
将操作按钮添加到索引
自定义表单
添加表单字段
移除表单字段
创建表单组
return Dynamo::make(\App\Employee::class)
->group(FieldGroup::make('groupName')
->text('fieldName')
->text('fieldName');
});
创建表单标签页
为字段添加自定义处理器
扩展Dynamo
创建自定义字段
为自定义字段创建处理器
高级Dynamo
在Dynamo模型之间创建多对多关系
步骤 1:生成您将使用的两个模型。
php artisan make:dynamo Faq
php artisan make:dynamo Category
步骤 2:完成所需的迁移。
示例 Faq 迁移
Schema::create('faqs', function (Blueprint $table) {
$table->increments('id');
$table->string('question', 255);
$table->mediumText('answer');
$table->timestamps();
});
示例 Category 迁移
Schema::create('categories', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->timestamps();
});
示例 pivot 表迁移
Schema::create('category_faq', function(Blueprint $table)
{
$table->integer('faq_id')->unsigned()->nullable();
$table->foreign('faq_id')->references('id')->on('faqs');
$table->integer('category_id')->unsigned()->nullable();
$table->foreign('category_id')->references('id')->on('categories');
});
运行 php artisan migrate
。
步骤 3:为每个模型添加适当的 belongsToMany Eloquent 函数。
对于 Category 模型
public function faqs()
{
return $this->belongsToMany('App\Faq');
}
对于 Faq 模型
public function categories()
{
return $this->belongsToMany('App\Category');
}
步骤 4:在两个控制器中将对 Dynamo 实例的 hasMany()
方法链。确保您的键是模型中 Eloquent 函数的名称。
return Dynamo::make(\App\Employee::class)
->hasMany('categories', ['options' => [$categories]]);
查看我们更详细的文档
https://dynamo-admin.readthedocs.io/en/latest/index.html
许可证
Dynamo 是开源软件,许可协议为 MIT 许可证。