提交代码
This commit is contained in:
64
app/Admin/Controllers/AccountController.php
Normal file
64
app/Admin/Controllers/AccountController.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Grid;
|
||||
use RuLong\Identity\Models\Identity;
|
||||
use RuLong\UserAccount\Models\UserAccount;
|
||||
|
||||
class AccountController extends AdminController
|
||||
{
|
||||
protected $title = '账户管理';
|
||||
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new UserAccount);
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableRowSelector();
|
||||
$grid->disableActions();
|
||||
$grid->disableColumnSelector();
|
||||
$grid->disableExport();
|
||||
$grid->model()->orderBy('cash', 'desc');
|
||||
|
||||
$grid->column('user_id', '用户序号')->sortable();
|
||||
$grid->column('用户名称')->display(function () {
|
||||
return $this->user->info->nickname;
|
||||
});
|
||||
$grid->column('级别')->display(function () {
|
||||
return $this->user->identity_text;
|
||||
});
|
||||
|
||||
$grid->column('cash', '余额')->display(function ($cash) {
|
||||
return "<span class='label label-warning'>" . number_format($cash, 1) . "</span>";
|
||||
})->sortable();
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(4, function ($filter) {
|
||||
$filter->equal('user_id', '用户序号');
|
||||
});
|
||||
$filter->column(4, function ($filter) {
|
||||
$filter->like('user.username', '用户账号');
|
||||
});
|
||||
|
||||
$filter->column(4, function ($filter) {
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('user.info', function ($query) {
|
||||
$query->where('nickname', 'like', "%{$this->input}%");
|
||||
});
|
||||
}, '用户名称');
|
||||
});
|
||||
|
||||
$filter->column(4, function ($filter) {
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('user', function ($query) {
|
||||
$query->whereHas('identity', function ($query) {
|
||||
$query->where('identity_id', $this->input);
|
||||
});
|
||||
});
|
||||
}, '级别')->select(Identity::pluck('title', 'id'));
|
||||
});
|
||||
});
|
||||
return $grid;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user