model()->orderBy('id', 'desc'); $grid->column('id')->sortable(); $grid->column('type')->using([1=>'传单', 2=>'桌牌'])->label([1=>'#28a745', 2=>'#007bff']); $grid->column('code')->image('', 50, 50); $grid->column('path'); $grid->column('owers', '头像')->display(function ($v) { if(_empty_($this->ower)){ return ''; } return ''; })->width('50px'); $grid->column('ower', '用户名称')->display(function ($v) { if(_empty_($this->code)){ $scene = 'from_user=itc'.$this->id; if($this->tenant_id !== null && $this->tenant_id >= 0){ if(!_empty_($scene)){ $scene .= '&'; } $scene .= 'tenant='.$this->tenant_id; } if(!_empty_($this->scene) && strlen($scene) < 32){ if(!_empty_($scene)){ $scene .= '&'; } $scene .= $this->scene; } $code = Utils::getMiniCode(_empty_default_($this->path, '/pages/tabbar/index/index') , $scene, 0, 430, false, null, true); \App\Models\User\WxUserInviteTempCode::where('id', $this->id)->update(['code' => $code]); } if($v && $v['user_name']){ return ''.$v['user_name'].'' ?? '用户已删除'; } return ''; })->width('100px'); $grid->column('shop_id'); $grid->column('club_id'); $grid->column('circle_id'); $grid->column('tag_id'); $grid->column('voter_id'); $grid->column('tenant_id'); $grid->column('status')->using([0=>'待绑定', 1=>'已绑定', 2=>'已解绑'])->label([0=>'#5ac725', 1=>'primary', 2=>'gray']); $grid->column('created_at'); $grid->column('updated_at')->sortable(); $grid->tools([ new UserInviteTmpCodeBatchButton(), new UserInviteTmpCodeBgButton() ]); $grid->filter(function (Grid\Filter $filter) { $filter->equal('id'); }); $grid->batchActions(function ($batch) { $batch->add(new UserInviteTmpCodeDownBatchAction()); $batch->add(new UserInviteTmpCodeBgDownBatchAction()); }); }); } /** * Make a show builder. * * @param mixed $id * * @return Show */ protected function detail($id) { return Show::make($id, new WxUserInviteTempCode(), function (Show $show) { $show->field('id'); $show->field('type'); $show->field('code'); $show->field('path'); $show->field('scene'); $show->field('with_target_type'); $show->field('with_target_id'); $show->field('user_id'); $show->field('shop_id'); $show->field('club_id'); $show->field('circle_id'); $show->field('tag_id'); $show->field('voter_id'); $show->field('tenant_id'); $show->field('status'); $show->field('created_at'); $show->field('updated_at'); }); } /** * Make a form builder. * * @return Form */ protected function form() { return Form::make(new WxUserInviteTempCode(), function (Form $form) { $form->display('id'); $form->radio('type')->options([1=>'传单', 2=>'桌牌'])->default(1); $form->text('path')->default('/pages/tabbar/index/index'); $form->text('user_id'); // $form->text('shop_id'); // $form->text('club_id'); // $form->text('circle_id'); // $form->text('tag_id'); // $form->text('voter_id'); $form->select('tenant_id')->options(WxTenant::orderBy('order', 'desc')->orderBy('tenant_id')->pluck('name', 'tenant_id')); // $form->text('status'); $form->display('created_at'); $form->display('updated_at'); }); } }