You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.0 KiB
83 lines
2.0 KiB
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Admin\Repositories\User;
|
|
use App\Common\UserStatus;
|
|
use Dcat\Admin\Form;
|
|
use Dcat\Admin\Grid;
|
|
use Dcat\Admin\Show;
|
|
use Dcat\Admin\Http\Controllers\AdminController;
|
|
|
|
class UserController extends AdminController
|
|
{
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
return Grid::make(new User('agent:id,name'), function (Grid $grid) {
|
|
$grid->disableRowSelector();
|
|
$grid->disableCreateButton();
|
|
$grid->disableActions();
|
|
|
|
$grid->column('id')->sortable();
|
|
$grid->column('agent.name', '所属代理商');
|
|
$grid->column('avatar')->image(60, 60);
|
|
$grid->column('mobile');
|
|
$grid->column('nickname');
|
|
$grid->column('status')->bool();
|
|
$grid->column('created_at');
|
|
$grid->column('updated_at');
|
|
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
$filter->panel();
|
|
|
|
$filter->equal('id')->width(1);
|
|
$filter->equal('mobile')->width(2);
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a show builder.
|
|
*
|
|
* @param mixed $id
|
|
*
|
|
* @return Show
|
|
*/
|
|
protected function detail($id)
|
|
{
|
|
return Show::make($id, new User(['agent:id,name']), function (Show $show) {
|
|
$show->disableDeleteButton();
|
|
|
|
$show->field('id');
|
|
$show->field('agent.name', '代理商');
|
|
$show->field('avatar')->image(80, 80);
|
|
$show->field('mobile');
|
|
$show->field('nickname');
|
|
$show->field('status')->bool();
|
|
$show->field('created_at');
|
|
$show->field('updated_at');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a form builder.
|
|
*
|
|
* @return Form
|
|
*/
|
|
protected function form()
|
|
{
|
|
return Form::make(new User(), function (Form $form) {
|
|
$form->disableDeleteButton();
|
|
|
|
/*$form->display('id');
|
|
$form->text('status');*/
|
|
})->deleting(function (Form $form) {
|
|
return $form->response()->error('禁止删除');
|
|
});
|
|
}
|
|
}
|