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.
110 lines
3.2 KiB
110 lines
3.2 KiB
<?php
|
|
|
|
namespace App\Admin\Controllers\v3;
|
|
|
|
use App\Admin\Repositories\v3\User;
|
|
use Dcat\Admin\Form;
|
|
use Dcat\Admin\Grid;
|
|
use Dcat\Admin\Show;
|
|
use Dcat\Admin\Controllers\AdminController;
|
|
use App\Models\v3\User as UserModel;
|
|
|
|
class UserController extends AdminController
|
|
{
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
return Grid::make(new User(), function (Grid $grid) {
|
|
$grid->column('id')->sortable();
|
|
$grid->column('avatar')->image('',50);
|
|
$grid->column('nick_name');
|
|
$grid->column('openid');
|
|
$grid->column('unionid');
|
|
$grid->column('real_name')->editable();
|
|
$grid->column('tel');
|
|
$grid->column('gender_text');
|
|
$grid->column('status')->using(UserModel::$_STATUS)->label(config('label.status_label'));
|
|
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
$filter->equal('id');
|
|
$filter->like('nick_name');
|
|
$filter->like('real_name');
|
|
});
|
|
$grid->model()->orderBy('id','desc');
|
|
// 每页10条
|
|
$grid->paginate(10);
|
|
$grid->disableCreateButton();
|
|
$grid->disableDeleteButton();
|
|
$grid->disableEditButton();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a show builder.
|
|
*
|
|
* @param mixed $id
|
|
*
|
|
* @return Show
|
|
*/
|
|
protected function detail($id)
|
|
{
|
|
return Show::make($id, new User(), function (Show $show) {
|
|
$show->field('id');
|
|
$show->field('nick_name');
|
|
$show->field('avatar')->image();
|
|
$show->field('openid');
|
|
$show->field('real_name');
|
|
$show->field('tel');
|
|
$show->field('unionid');
|
|
$show->field('status');
|
|
$show->field('country');
|
|
$show->field('province');
|
|
$show->field('city');
|
|
$show->field('gender');
|
|
$show->field('language');
|
|
$show->field('created_at');
|
|
$show->field('updated_at');
|
|
|
|
$show->panel()->tools(function ($tools) {
|
|
$tools->disableEdit();
|
|
// $tools->disableList();
|
|
$tools->disableDelete();
|
|
// 显示快捷编辑按钮
|
|
// $tools->showQuickEdit();
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a form builder.
|
|
*
|
|
* @return Form
|
|
*/
|
|
protected function form()
|
|
{
|
|
return Form::make(new User(), function (Form $form) {
|
|
$form->hidden('id');
|
|
$form->text('nick_name');
|
|
$form->image('avatar');
|
|
$form->text('openid');
|
|
$form->text('real_name');
|
|
$form->tel('tel');
|
|
$form->text('unionid');
|
|
$form->text('status');
|
|
$form->text('country');
|
|
$form->text('province');
|
|
$form->text('city');
|
|
$form->radio('gender')->options(UserModel::$_GENDER);
|
|
$form->text('language');
|
|
|
|
$form->disableResetButton();
|
|
$form->disableViewCheck();
|
|
$form->disableEditingCheck();
|
|
$form->disableCreatingCheck();
|
|
});
|
|
}
|
|
}
|