123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- namespace App\Admin\Controllers;
- use App\Admin\Repositories\WxNotice;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Dcat\Admin\Http\Controllers\AdminController;
- class WxNoticeController extends AdminController
- {
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- return Grid::make(new WxNotice('user'), function (Grid $grid) {
- $grid->simplePaginate();
- $grid->model()->orderBy('id','desc');
- // $grid->column('id')->sortable();
- $grid->column('user.user_avatar', '用户头像')->image('', 50);
- $grid->column('user.user_name', '用户名');
- $grid->column('title');
- $grid->column('content')->limit(8);
- $grid->column('is_read')->using([0 => '用户未读', 1 => '用户已读'])->label([
- 0 => 'red',
- 1 => 'primary',
- ]);
- $grid->column('notice_type')->using([0 => '系统通知', 1 => '活动通知', 2 => '点赞通知', 3 => '收藏通知', 4 => '评论通知', 5 => '评论点赞通知', 8 => '发货通知'])->label([
- 0 => 'blue',
- 1 => 'primary',
- 2 => 'red',
- 3 => 'green',
- 4 => 'orange2',
- 5 => 'pink',
- 8 => 'primary',
- ]);
- $grid->column('created_at');
- $grid->column('updated_at')->sortable();
- $grid->filter(function (Grid\Filter $filter) {
- $filter->equal('id');
- });
- $grid->disableCreateButton();
- $grid->disableActions();
- $grid->disableBatchDelete();
- });
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- *
- * @return Show
- */
- protected function detail($id)
- {
- return Show::make($id, new WxNotice(), function (Show $show) {
- $show->field('id');
- $show->field('user_id');
- $show->field('posts_id');
- $show->field('title');
- $show->field('content');
- $show->field('is_read');
- $show->field('notice_type');
- $show->field('created_at');
- $show->field('updated_at');
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- return Form::make(new WxNotice(), function (Form $form) {
- $form->display('id');
- $form->text('user_id');
- $form->text('posts_id');
- $form->text('title');
- $form->text('content');
- $form->text('is_read');
- $form->text('notice_type');
- $form->deleting(function (Form $form){
- global $__MINI_GLOBAL_TENANT_ID__;
- if($__MINI_GLOBAL_TENANT_ID__ > 0){
- return $form->response()->error('权限不足,不可以删除其他分站对象');
- }
- });
- });
- }
- }
|