| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace App\Admin\Controllers;
- use App\Admin\Repositories\Msg;
- use App\Models\User;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Dcat\Admin\Http\Controllers\AdminController;
- class MsgController extends AdminController
- {
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- return Grid::make(new Msg(), function (Grid $grid) {
- $grid->model()->orderByDesc("id");
- $grid->column('id')->sortable();
- // $grid->column('type');
- // $grid->column('user_id');
- // $grid->column('to_user_id');
- $grid->column('title');
- $grid->column('content');
- $grid->column('created_at');
- $grid->column('updated_at')->sortable();
- $grid->actions(function (Grid\Displayers\Actions $actions) {
- $actions->disableEdit();
- $actions->disableView();
- });
- $grid->filter(function (Grid\Filter $filter) {
- $filter->panel();
- $filter->like('title')->width(4);
- $filter->like('content')->width(4);
- });
- });
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- *
- * @return Show
- */
- protected function detail($id)
- {
- return Show::make($id, new Msg(), function (Show $show) {
- $show->field('id');
- $show->field('type');
- $show->field('user_id');
- $show->field('to_user_id');
- $show->field('title');
- $show->field('content');
- $show->field('created_at');
- $show->field('updated_at');
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- return Form::make(new Msg(), function (Form $form) {
- $form->display('id');
- $form->hidden('type')->default(6);
- $form->hidden('user_id')->default(0);
- $form->select('to_user_id')->options(function ($item){
- return User::pluck('name','id');
- });
- $form->hidden('title')->default("系统通知");
- $form->textarea('content');
- $form->display('created_at');
- $form->display('updated_at');
- });
- }
- }
|