Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zhaiduting/column-relation
column-relation extension for laravel-admin
https://github.com/zhaiduting/column-relation
Last synced: about 1 month ago
JSON representation
column-relation extension for laravel-admin
- Host: GitHub
- URL: https://github.com/zhaiduting/column-relation
- Owner: zhaiduting
- License: mit
- Created: 2020-02-16T07:41:27.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T07:59:05.000Z (almost 2 years ago)
- Last Synced: 2024-10-29T00:55:57.763Z (about 1 month ago)
- Language: PHP
- Homepage:
- Size: 3.71 MB
- Stars: 12
- Watchers: 2
- Forks: 2
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-laravel-admin - column-relation - 内联表格,自动加页码 (扩展包 / 网格类扩展包)
README
Column-relation extension for laravel-admin
======
# 安装
`composer require zhaiduting/column-relation`
# 注册扩展
在文件 app\Admin\bootstrap.php 中添加如下代码
```
// Add the following code to the file app\Admin\bootstrap.phpuse Encore\Admin\Table\Column;
use Zhaiduting\ColumnRelation\Relate;Column::extend('relate', Relate::class);
```
# 使用
在 laravel-admin 的控制器中,可以类似于下面这样使用 relate(..)
```
// e.g: use relate(..) in the app\Admin\Controllers\RoleController.php as followsprotected function table()
{
$table = new Table(new Role());$table->column('id', __('Id'));
$table->column('name', '角色名称')
->relate('users', ['id', 'name'=> '用户'], function($user){
$user->name=
"id). "'>".
" ".
$user->name.
"";
});
$table->column('permissions', '权限')->pluck('name')->label('default');return $table;
}
```
![example.gif](https://github.com/zhaiduting/column-relation/blob/master/example.gif)