header('微信平台列表') ->description('') ->body($this->grid()); } /** * Show interface. * * @param mixed $id * @param Content $content * @return Content */ public function show($id, Content $content) { return $content ->header('微信平台列表') ->description('详细') ->body($this->detail($id)); } /** * Edit interface. * * @param mixed $id * @param Content $content * @return Content */ public function edit($id, Content $content) { return $content ->header('微信平台列表') ->description('编辑') ->body($this->editForm($id)->edit($id)); } /** * Create interface. * * @param Content $content * @return Content */ public function create(Content $content) { return $content ->header('微信平台列表') ->description('创建') ->body($this->createForm()); } /** * Make a grid builder. * * @return Grid */ protected function grid() { $grid = new Grid(new WeiXin); $grid->id('ID'); $grid->name('公众号名称'); $grid->number('微信号'); $grid->images('微信二维码图片')->image('', 100, 100); $grid->created_at('添加时间'); $grid->updated_at('更新时间'); return $grid; } /** * Make a show builder. * * @param mixed $id * @return Show */ protected function detail($id) { $show = new Show(WeiXin::findOrFail($id)); $show->id('ID'); $show->name('公众号名称'); $show->number('微信号'); $show->app_token('AppToken'); $show->app_id('AppId'); $show->encoding_ase_key('EncodingAESKey'); $show->images('微信二维码图片'); $show->created_at('添加时间'); $show->updated_at('更新时间'); return $show; } /** * Make a form builder. * * @return Form */ protected function editForm($id) { $form = new Form(new WeiXin); $form->display('name', '公众号名称'); $form->display('number', '微信号'); $form->text('app_token', 'AppToken')->rules([ 'required', ]); $form->text('app_id', 'AppId')->rules([ 'required', Rule::unique('wei_xins')->ignore($id), ]); $form->password('app_secret', 'AppSecret')->rules([ 'required', ]); $form->text('encoding_ase_key', 'EncodingAESKey'); $form->image('images', '微信二维码图片')->uniqueName(); $form->tools(function (Form\Tools $tools) { $tools->disableDelete(); }); return $form; } protected function createForm() { $form = new Form(new WeiXin); $form->text('name', '公众号名称')->rules([ 'required', 'unique:wei_xins', ]); $form->text('number', '微信号')->rules([ 'required', 'unique:wei_xins', ]); $form->text('app_token', 'AppToken')->rules([ 'required', ]); $form->text('app_id', 'AppId')->rules([ 'required', 'unique:wei_xins', ]); $form->text('app_secret', 'AppSecret')->rules([ 'required', ]); $form->text('encoding_ase_key', 'EncodingAESKey')->placeholder('消息加解密密钥'); $form->image('images', '微信二维码图片')->uniqueName(); $form->tools(function (Form\Tools $tools) { $tools->disableDelete(); }); return $form; } /** * Store a newly created resource in storage. * * @return mixed */ public function store() { return $this->createForm()->store(); } /** * Update the specified resource in storage. * * @param int $id * * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response */ public function update($id) { return $this->editForm($id)->update($id); } /** * Make a form builder. * * @return Form */ protected function form() { $form = new Form(new WeiXin); $form->display('ID'); $form->display('Created at'); $form->display('Updated at'); return $form; } }