123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- namespace App\Admin\Controllers\Voter;
- use App\Admin\Repositories\Voter\WxVoterTemplate;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Dcat\Admin\Http\Controllers\AdminController;
- class WxVoterTemplateController extends AdminController
- {
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- return Grid::make(new WxVoterTemplate(), function (Grid $grid) {
- $grid->model()->orderBy('id', 'desc');
- $grid->column('id')->sortable();
- $grid->column('status')->switch();
- // $grid->column('recommend');
- $grid->column('sort')->editable();
- $grid->column('name')->editable();
- // $grid->column('template_type');
- $grid->column('cover')->image();
- // $grid->column('banner');
- // $grid->column('main_background_image');
- // $grid->column('user_background_image');
- $grid->column('background_color')->editable();
- $grid->column('text_color')->editable();
- $grid->column('main_color')->editable();
- $grid->column('button_bg_color')->editable();
- $grid->column('button_text_color')->editable();
- $grid->column('text_navigation_bar_color')->editable();
- // $grid->column('created_at');
- $grid->column('updated_at')->sortable();
- $grid->filter(function (Grid\Filter $filter) {
- $filter->equal('id');
- });
- });
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- *
- * @return Show
- */
- protected function detail($id)
- {
- return Show::make($id, new WxVoterTemplate(), function (Show $show) {
- $show->field('id');
- $show->field('status');
- $show->field('recommend');
- $show->field('sort');
- $show->field('name');
- $show->field('template_type');
- $show->field('cover');
- $show->field('banner');
- $show->field('main_background_image');
- $show->field('user_background_image');
- $show->field('background_color');
- $show->field('text_color');
- $show->field('main_color');
- $show->field('button_bg_color');
- $show->field('button_text_color');
- $show->field('text_navigation_bar_color');
- $show->field('created_at');
- $show->field('updated_at');
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- return Form::make(new WxVoterTemplate(), function (Form $form) {
- $form->display('id');
- $form->switch('status')->default(1);
- // $form->text('recommend');
- // $form->text('sort');
- $form->text('name')->required();
- // $form->text('template_type');
- $form->image('cover')->url('files/uploads')->autoUpload()->required();
- $form->multipleImage('banner')->url('files/uploads')->autoUpload()->saveAsJson()->required();
- $form->image('main_background_image')->url('files/uploads')->autoUpload();
- $form->image('user_background_image');
- $form->color('background_color')->required();
- $form->color('text_color')->required();
- $form->color('main_color')->required();
- $form->color('button_bg_color')->required();
- $form->color('button_text_color')->required();
- $form->color('text_navigation_bar_color')->required()->default('#000000');
- $form->display('created_at');
- $form->display('updated_at');
- $form->deleting(function (Form $form){
- global $__MINI_GLOBAL_TENANT_ID__;
- if($__MINI_GLOBAL_TENANT_ID__ > 0){
- return $form->response()->error('权限不足,不可以删除其他分站对象');
- }
- });
- });
- }
- }
|