DistProductParameterController.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. namespace App\Distributor\Controllers;
  3. use App\Distributor\Repositories\DistProductParameter;
  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 DistProductParameterController extends AdminDistController
  11. {
  12. /**
  13. * page index
  14. */
  15. public function index(Content $content)
  16. {
  17. return $content
  18. ->view('distributor.layouts.content')
  19. ->header(admin_trans( 'admin.product_parameter'))
  20. ->description(admin_trans('admin.all'))
  21. ->breadcrumb(['text'=>'list','url'=>''])
  22. ->body($this->grid());
  23. }
  24. /**
  25. * Edit interface.
  26. *
  27. * @param mixed $id
  28. * @param Content $content
  29. * @return Content
  30. */
  31. public function edit($id, Content $content)
  32. {
  33. return $content
  34. ->view('distributor.layouts.content')
  35. ->translation($this->translation())
  36. ->title($this->title())
  37. ->description($this->description()['edit'] ?? trans('admin.edit'))
  38. ->body($this->form()->edit($id));
  39. }
  40. /**
  41. * Create interface.
  42. *
  43. * @param Content $content
  44. * @return Content
  45. */
  46. public function create(Content $content)
  47. {
  48. return $content
  49. ->view('distributor.layouts.content')
  50. ->translation($this->translation())
  51. ->title($this->title())
  52. ->description($this->description()['create'] ?? trans('admin.create'))
  53. ->body($this->form());
  54. }
  55. /**
  56. * Make a grid builder.
  57. *
  58. * @return Grid
  59. */
  60. protected function grid()
  61. {
  62. return Grid::make(new DistProductParameter(), function (Grid $grid) {
  63. $grid->column('id')->sortable();
  64. $grid->column('name');
  65. $grid->column('order');
  66. $grid->column('enabled');
  67. $grid->column('content');
  68. $grid->column('created_at');
  69. $grid->column('updated_at')->sortable();
  70. $grid->filter(function (Grid\Filter $filter) {
  71. $filter->equal('id');
  72. });
  73. });
  74. }
  75. /**
  76. * Make a show builder.
  77. *
  78. * @param mixed $id
  79. *
  80. * @return Show
  81. */
  82. protected function detail($id)
  83. {
  84. return Show::make($id, new DistProductParameter(), function (Show $show) {
  85. $show->field('id');
  86. $show->field('name');
  87. $show->field('order');
  88. $show->field('enabled');
  89. $show->field('content');
  90. $show->field('created_at');
  91. $show->field('updated_at');
  92. });
  93. }
  94. /**
  95. * Make a form builder.
  96. *
  97. * @return Form
  98. */
  99. protected function form()
  100. {
  101. return Form::make(new DistProductParameter(), function (Form $form) {
  102. $form->display('id');
  103. $form->text('name');
  104. $form->text('order');
  105. $form->text('enabled');
  106. $form->text('content');
  107. $form->display('created_at');
  108. $form->display('updated_at');
  109. });
  110. }
  111. }