UsersReportController.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\UserReportModel;
  4. use App\Models\UsersReport;
  5. use Dcat\Admin\Form;
  6. use Dcat\Admin\Grid;
  7. use Dcat\Admin\Show;
  8. use Dcat\Admin\Http\Controllers\AdminController;
  9. class UsersReportController extends AdminController
  10. {
  11. /**
  12. * Make a grid builder.
  13. *
  14. * @return Grid
  15. */
  16. protected function grid()
  17. {
  18. $grid = new Grid(new UserReportModel());
  19. $grid->model()->orderByDesc('id');
  20. $grid->column('id')->sortable();
  21. $grid->column('user_id');
  22. $grid->column('report_id');
  23. $grid->column('type');
  24. $grid->column('content');
  25. $grid->column('info');
  26. $grid->column('img_url');
  27. $grid->column('status');
  28. $grid->column('created_at');
  29. $grid->column('updated_at')->sortable();
  30. $grid->filter(function (Grid\Filter $filter) {
  31. $filter->equal('id');
  32. });
  33. return $grid;
  34. }
  35. /**
  36. * Make a show builder.
  37. *
  38. * @param mixed $id
  39. *
  40. * @return Show
  41. */
  42. protected function detail($id)
  43. {
  44. return Show::make($id, new UserReportModel(), function (Show $show) {
  45. $show->field('id');
  46. $show->field('user_id');
  47. $show->field('report_id');
  48. $show->field('type');
  49. $show->field('content');
  50. $show->field('info');
  51. $show->field('img_url');
  52. $show->field('status');
  53. $show->field('created_at');
  54. $show->field('updated_at');
  55. });
  56. }
  57. /**
  58. * Make a form builder.
  59. *
  60. * @return Form
  61. */
  62. protected function form()
  63. {
  64. return Form::make(new UserReportModel(), function (Form $form) {
  65. $form->display('id');
  66. $form->text('user_id');
  67. $form->text('report_id');
  68. $form->text('type');
  69. $form->text('content');
  70. $form->text('info');
  71. $form->text('img_url');
  72. $form->text('status');
  73. $form->display('created_at');
  74. $form->display('updated_at');
  75. });
  76. }
  77. }