123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- namespace App\Admin\Controllers\User;
- use App\Admin\Repositories\User\WxUserReport;
- use App\Wen\Utils\FieldUtils;
- use App\Wen\Utils\Utils;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Dcat\Admin\Http\Controllers\AdminController;
- class WxUserReportController extends AdminController
- {
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- return Grid::make(new WxUserReport(), function (Grid $grid) {
- $grid->simplePaginate();
- $grid->quickSearch(['id', 'user_id', 'object_id'])->placeholder('搜索id,用户id...')->width(35);
- $grid->model()->orderBy('id', 'desc');
- $grid->column('id')->sortable();
- $grid->column('type')->using([0=>'笔记', 1=> '评论', 2 => '用户', 3=> '商品']);
- $grid->column('user_id')->display(function ($v){
- return '<a href="'.admin_url('users?id='.$v).'" target="_blank"> '.$v.'</a>';
- });
- $grid->column('object_id');
- $grid->column('report_type')->using(FieldUtils::getReportTypes());
- $grid->column('report_message');
- $grid->column('report_imgs')->display(function ($v) {
- if(_empty_($v)){
- return '';
- }
- $imgs = explode(',', $v);
- $html = '<div style="max-width: 350px; overflow-x: scroll;">';
- foreach ($imgs as $img){
- $html .= '<img data-action="preview-img" style="max-width: 50px;margin-right: 10px;" src="'.Utils::imgWithStyle($img).'" / >';
- }
- return $html.'</div>';
- })->width('50px');
- $grid->column('contact');
- // $grid->column('created_at');
- $grid->column('updated_at')->sortable();
- $grid->filter(function (Grid\Filter $filter) {
- $filter->equal('id');
- });
- $grid->disableViewButton();
- $grid->disableCreateButton();
- $grid->disableActions();
- $grid->disableBatchActions();
- });
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- *
- * @return Show
- */
- protected function detail($id)
- {
- return Show::make($id, new WxUserReport(), function (Show $show) {
- $show->field('id');
- $show->field('type');
- $show->field('user_id');
- $show->field('object_id');
- $show->field('report_type');
- $show->field('report_message');
- $show->field('created_at');
- $show->field('updated_at');
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- return Form::make(new WxUserReport(), function (Form $form) {
- $form->display('id');
- $form->text('type');
- $form->text('user_id');
- $form->text('object_id');
- $form->text('report_type');
- $form->text('report_message');
- $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('权限不足,不可以删除其他分站对象');
- }
- });
- });
- }
- }
|