123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- namespace App\Admin\Controllers;
- use App\Admin\Actions\Users\Report;
- use App\Models\UserFeedback;
- use App\Models\UserReportModel;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Dcat\Admin\Http\Controllers\AdminController;
- use Illuminate\Database\Eloquent\Model;
- class UserFeedbackController extends AdminController
- {
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- $grid = new Grid(new UserFeedback());
- $grid->model()->with(['user:id,name'])->orderByDesc('id');
- $grid->column('id')->sortable();
- $grid->column('user.name', trans('user-feedback.fields.user_id'));
- $grid->column('content');
- $grid->column('file')->display(function ($file) {
- return json_decode($file, true);
- })->image('', '60', '60');
- $grid->column('status')->using([0 => trans('user-report.fields.untreated'), 1 => trans('user-report.fields.processed')])->label(['red', 'green']);
- $grid->column('created_at');
- $grid->filter(function (Grid\Filter $filter) {
- $filter->equal('id');
- $filter->like('user.name');
- $filter->like('content');
- $filter->equal('status')->select(['0' => trans('user-report.fields.untreated'), '1' => trans('user-report.fields.processed')]);
- });
- $grid->actions(function (Grid\Displayers\Actions $actions) {
- $actions->disableView();
- $actions->disableEdit();
- $actions->disableDelete();
- if ($actions->row->status == 0) {
- $actions->append(new Report(UserFeedback::class));
- }
- });
- return $grid;
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- *
- * @return Show
- */
- protected function detail($id)
- {
- return Show::make($id, new UserFeedback(), function (Show $show) {
- $show->field('id');
- $show->field('user_id');
- $show->field('content');
- $show->field('file');
- $show->field('status');
- $show->field('created_at');
- $show->field('updated_at');
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- return Form::make(new UserFeedback(), function (Form $form) {
- $form->display('id');
- $form->text('user_id');
- $form->text('content');
- $form->text('file');
- $form->text('status');
- $form->display('created_at');
- $form->display('updated_at');
- $form->footer(function ($footer) {
- // 去掉`查看`checkbox
- $footer->disableViewCheck();
- // 去掉`继续编辑`checkbox
- $footer->disableEditingCheck();
- // 去掉`继续创建`checkbox
- $footer->disableCreatingCheck();
- });
- });
- }
- }
|