SiteAlbumLogController.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\SiteAlbumLog;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. use Dcat\Admin\Layout\Content;
  9. use Dcat\Admin\Admin;
  10. class SiteAlbumLogController extends AdminController
  11. {
  12. /**
  13. * page index
  14. */
  15. public function index(Content $content)
  16. {
  17. return $content
  18. ->header('列表')
  19. ->description('全部')
  20. ->breadcrumb(['text'=>'列表','url'=>''])
  21. ->body($this->grid());
  22. }
  23. /**
  24. * Make a grid builder.
  25. *
  26. * @return Grid
  27. */
  28. protected function grid()
  29. {
  30. return Grid::make(new SiteAlbumLog(), function (Grid $grid) {
  31. $grid->column('id')->sortable();
  32. $grid->column('user_name');
  33. $grid->column('action');
  34. $grid->column('model');
  35. $grid->column('content')->display(function ($value) {
  36. $value = json_decode($value, true);
  37. if (empty($value) == false) {
  38. return implode(' | ', $value);
  39. }
  40. return '';
  41. });
  42. $grid->column('created_at');
  43. $grid->column('updated_at')->sortable();
  44. //搜索
  45. $grid->filter(function (Grid\Filter $filter) {
  46. $filter->panel();
  47. $filter->expand();
  48. $filter->equal('nick_name')->width(2);
  49. $filter->equal('model')->width(2);
  50. });
  51. //按钮
  52. $grid->disableCreateButton();
  53. $grid->disableDeleteButton();
  54. $grid->disableEditButton();
  55. $grid->disableActions();
  56. $grid->model()->orderBy('id', 'desc');
  57. });
  58. }
  59. /**
  60. * Make a show builder.
  61. *
  62. * @param mixed $id
  63. *
  64. * @return Show
  65. */
  66. protected function detail($id)
  67. {
  68. return Show::make($id, new SiteAlbumLog(), function (Show $show) {
  69. $show->field('id');
  70. $show->field('user_name');
  71. $show->field('action');
  72. $show->field('model');
  73. $show->field('content');
  74. $show->field('created_at');
  75. $show->field('updated_at');
  76. });
  77. }
  78. }