12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace App\Admin\Controllers\User;
- use App\Admin\Repositories\User\WxUserVote;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Dcat\Admin\Http\Controllers\AdminController;
- class WxUserVoteController extends AdminController
- {
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- return Grid::make(new WxUserVote(), function (Grid $grid) {
- $grid->model()->orderBy('id','desc');
- $grid->simplePaginate();
- $grid->column('id')->sortable();
- $grid->column('user_id');
- $grid->column('user')->display(function ($v) {
- if($v && $v['user_name']){
- return '<a target="_blank" href="'.admin_url('users?id='.$v['id']).'">'.$v['user_name'].'</a>' ?? '用户已删除';
- }
- return '用户已删除';
- })->width('100px');
- $grid->column('vote_id');
- $grid->column('vote_option');
- // $grid->column('vote_title');
- // $grid->column('created_at');
- $grid->column('updated_at')->sortable();
- $grid->filter(function (Grid\Filter $filter) {
- $filter->equal('id');
- });
- $grid->disableActions();
- $grid->disableBatchActions();
- $grid->disableCreateButton();
- });
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- *
- * @return Show
- */
- protected function detail($id)
- {
- return Show::make($id, new WxUserVote(), function (Show $show) {
- $show->field('id');
- $show->field('user_id');
- $show->field('vote_id');
- $show->field('vote_option');
- $show->field('created_at');
- $show->field('updated_at');
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- return Form::make(new WxUserVote(), function (Form $form) {
- $form->display('id');
- $form->text('user_id');
- $form->text('vote_id');
- $form->text('vote_option');
- $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('权限不足,不可以删除其他分站对象');
- }
- });
- });
- }
- }
|