MsgController.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Repositories\Msg;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class MsgController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new Msg(), function (Grid $grid) {
  18. $grid->model()->orderByDesc("id");
  19. $grid->column('id')->sortable();
  20. // $grid->column('type');
  21. // $grid->column('user_id');
  22. // $grid->column('to_user_id');
  23. $grid->column('title');
  24. $grid->column('content');
  25. $grid->column('created_at');
  26. $grid->column('updated_at')->sortable();
  27. $grid->actions(function (Grid\Displayers\Actions $actions) {
  28. $actions->disableEdit();
  29. $actions->disableView();
  30. });
  31. $grid->filter(function (Grid\Filter $filter) {
  32. $filter->panel();
  33. $filter->like('title');
  34. $filter->like('content');
  35. });
  36. });
  37. }
  38. /**
  39. * Make a show builder.
  40. *
  41. * @param mixed $id
  42. *
  43. * @return Show
  44. */
  45. protected function detail($id)
  46. {
  47. return Show::make($id, new Msg(), function (Show $show) {
  48. $show->field('id');
  49. $show->field('type');
  50. $show->field('user_id');
  51. $show->field('to_user_id');
  52. $show->field('title');
  53. $show->field('content');
  54. $show->field('created_at');
  55. $show->field('updated_at');
  56. });
  57. }
  58. /**
  59. * Make a form builder.
  60. *
  61. * @return Form
  62. */
  63. protected function form()
  64. {
  65. return Form::make(new Msg(), function (Form $form) {
  66. $form->display('id');
  67. $form->hidden('type')->default(6);
  68. $form->hidden('user_id')->default(0);
  69. $form->hidden('to_user_id')->default(0);
  70. $form->hidden('title')->default("系统通知");
  71. $form->textarea('content');
  72. $form->display('created_at');
  73. $form->display('updated_at');
  74. });
  75. }
  76. }