Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/zhaiduting/column-relation

column-relation extension for laravel-admin
https://github.com/zhaiduting/column-relation

Last synced: 6 days ago
JSON representation

column-relation extension for laravel-admin

Awesome Lists containing this project

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.php

use 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 follows

protected 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)