column('id')->sortable(); $grid->column('owers', '头像')->display(function ($v) { if($this->ower['user_avatar'] ?? '') { return ''; } return ''; })->width('50px'); $grid->column('ower')->display(function ($v) { if($v && $v['user_name']){ return ''.$v['user_name'].'' ?? '用户已删除'; } return ''; })->width('100px'); $grid->column('posts_id')->display(function ($v){ if($v){ return '笔记'.$v.''; } return ''; }); $grid->column('content'); $grid->column('img'); $grid->column('expect_time'); $grid->column('publish_time'); $grid->column('status')->using([0=>'待发布', 1=>'已发布'])->label([0=>'gray', 1=>'primary']); $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 WxPostsCommentManual(), function (Show $show) { $show->field('id'); $show->field('posts_id'); $show->field('expect_user'); $show->field('content'); $show->field('img'); $show->field('expect_time'); $show->field('publish_time'); $show->field('status'); }); } /** * Make a form builder. * * @return Form */ protected function form() { return Form::make(new WxPostsCommentManual(), function (Form $form) { $form->display('id'); $form->text('posts_id')->default(Cache::get('posts_comment_manual_last_post_id', ''))->required(); $form->select('expect_user', '用户')->options(function ($id) { if($id){ $user = \App\Models\User\WxUser::find($id); if ($user) { return [$user->id => $user->user_name]; } } })->ajax('select/users'); $form->textarea('content')->required(); $form->image('img')->url('files/uploads')->autoUpload(); $expect_time = \App\Models\Posts\WxPostsCommentManual::where('status', 0)->max('expect_time'); if(_empty_($expect_time)){ $expect_time = current_time(); }else{ $expect_time = Carbon::parse($expect_time); $now = Carbon::now(); // 比较时间 if ($expect_time->lessThan($now)) { $expect_time = $now; }else{ $expect_time = Carbon::parse($expect_time)->addMinutes(mini_rand(1, 20)); } } $form->datetime('expect_time')->default($expect_time)->required(); // $form->text('publish_time'); // $form->text('status'); }); } }