5 changed files with 142 additions and 11 deletions
@ -0,0 +1,106 @@
@@ -0,0 +1,106 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Models\Config; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
||||
class ConfigController extends AdminController |
||||
{ |
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new Config(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
|
||||
$grid->model()->where("unique_identification", "annual_session"); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('data'); |
||||
$grid->column('remark'); |
||||
$grid->column('create_time'); |
||||
$grid->column('update_time'); |
||||
|
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('id'); |
||||
|
||||
}); |
||||
|
||||
// 禁用创建按钮 |
||||
$grid->disableCreateButton(); |
||||
// 禁用删除按钮 |
||||
$grid->disableDeleteButton(); |
||||
//禁用批量操作按钮 |
||||
$grid->disableBatchDelete(); |
||||
|
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new Config(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('unique_identification'); |
||||
$show->field('data'); |
||||
$show->field('create_time'); |
||||
$show->field('update_time'); |
||||
$show->field('remark'); |
||||
$show->field('created_at'); |
||||
$show->field('updated_at'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new Config(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->hidden('unique_identification'); |
||||
$form->text('data')->required(); |
||||
$form->text('remark')->required(); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
}); |
||||
} |
||||
} |
Loading…
Reference in new issue