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.
132 lines
3.6 KiB
132 lines
3.6 KiB
<?php |
|
|
|
namespace App\Admin\Controllers; |
|
|
|
use App\Admin\Repositories\WechatAppConfig; |
|
use Dcat\Admin\Form; |
|
use Dcat\Admin\Grid; |
|
use Dcat\Admin\Show; |
|
use Dcat\Admin\Http\Controllers\AdminController; |
|
|
|
class WechatAppConfigController extends AdminController |
|
{ |
|
/** |
|
* Make a grid builder. |
|
* |
|
* @return Grid |
|
*/ |
|
protected function grid() |
|
{ |
|
return Grid::make(new WechatAppConfig(), function (Grid $grid) { |
|
//开启边框模式 |
|
$grid->withBorder(); |
|
// 开启字段选择器功能 |
|
$grid->showColumnSelector(); |
|
|
|
$grid->column('id')->sortable(); |
|
$grid->column('name'); |
|
$grid->column('miniapp_id'); |
|
$grid->column('mch_id'); |
|
$grid->column('key'); |
|
$grid->column('notify_url'); |
|
$grid->column('create_time')->display(function (){ |
|
if(!empty($this->create_time)){ |
|
return date("Y-m-d H:i:s", $this->create_time); |
|
} |
|
})->sortable(); |
|
|
|
$grid->filter(function (Grid\Filter $filter) { |
|
$filter->equal('id'); |
|
|
|
}); |
|
|
|
// 禁用删除按钮 |
|
$grid->disableDeleteButton(); |
|
//禁用批量操作按钮 |
|
$grid->disableBatchDelete(); |
|
// 禁用详情按钮 |
|
$grid->disableViewButton(); |
|
// 禁用创建按钮 |
|
$grid->disableCreateButton(); |
|
}); |
|
} |
|
|
|
/** |
|
* Make a show builder. |
|
* |
|
* @param mixed $id |
|
* |
|
* @return Show |
|
*/ |
|
protected function detail($id) |
|
{ |
|
return Show::make($id, new WechatAppConfig(), function (Show $show) { |
|
$show->field('id'); |
|
$show->field('name'); |
|
$show->field('app_id'); |
|
$show->field('miniapp_id'); |
|
$show->field('appid'); |
|
$show->field('mch_id'); |
|
$show->field('key'); |
|
$show->field('notify_url'); |
|
$show->field('cert_pem'); |
|
$show->field('key_pem'); |
|
$show->field('status'); |
|
$show->field('create_time'); |
|
$show->field('update_time'); |
|
}); |
|
} |
|
|
|
/** |
|
* Make a form builder. |
|
* |
|
* @return Form |
|
*/ |
|
protected function form() |
|
{ |
|
return Form::make(new WechatAppConfig(), function (Form $form) { |
|
$form->display('id'); |
|
$form->text('name'); |
|
$form->text('miniapp_id'); |
|
$form->text('mch_id'); |
|
$form->text('key'); |
|
$form->text('notify_url'); |
|
$form->textarea('cert_pem'); |
|
$form->textarea('key_pem'); |
|
|
|
$form->hidden("create_time"); |
|
$form->hidden("update_time"); |
|
|
|
// 去除删除按钮 |
|
$form->disableDeleteButton(); |
|
|
|
// 去除跳转详情按钮 |
|
$form->disableViewButton(); |
|
|
|
$form->footer(function ($footer) { |
|
|
|
// 去掉`查看`checkbox |
|
$footer->disableViewCheck(); |
|
|
|
// 去掉`继续编辑`checkbox |
|
$footer->disableEditingCheck(); |
|
|
|
// 去掉`继续创建`checkbox |
|
$footer->disableCreatingCheck(); |
|
|
|
}); |
|
|
|
$form->saving(function (Form $form) { |
|
|
|
if ($form->isCreating()) { |
|
$form->create_time =time(); |
|
// 删除用户提交的数据 |
|
$form->deleteInput('update_time'); |
|
}else{ |
|
$form->update_time =time(); |
|
} |
|
}); |
|
|
|
}); |
|
} |
|
}
|
|
|