链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
2.5 KiB

6 years ago
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Repositories\Goods;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Controllers\AdminController;
  8. class GoodsController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new Goods(), function (Grid $grid) {
  18. $grid->id->sortable();
  19. $grid->cover_img;
  20. $grid->name;
  21. $grid->type_id;
  22. $grid->store_id;
  23. $grid->price;
  24. $grid->sort;
  25. $grid->on_sale;
  26. $grid->filter(function (Grid\Filter $filter) {
  27. $filter->equal('id');
  28. });
  29. });
  30. }
  31. /**
  32. * Make a show builder.
  33. *
  34. * @param mixed $id
  35. *
  36. * @return Show
  37. */
  38. protected function detail($id)
  39. {
  40. return Show::make($id, new Goods(), function (Show $show) {
  41. $show->id;
  42. $show->name;
  43. $show->type_id;
  44. $show->store_id;
  45. $show->cover_img;
  46. $show->price;
  47. $show->original_price;
  48. $show->vip_price;
  49. $show->on_sale;
  50. $show->inventory;
  51. $show->content;
  52. $show->sort;
  53. $show->restrict_num;
  54. $show->start_num;
  55. $show->is_infinite;
  56. $show->good_unit;
  57. $show->tags;
  58. $show->details_imgs;
  59. $show->spec;
  60. $show->created_at;
  61. $show->updated_at;
  62. });
  63. }
  64. /**
  65. * Make a form builder.
  66. *
  67. * @return Form
  68. */
  69. protected function form()
  70. {
  71. return Form::make(new Goods(), function (Form $form) {
  72. $form->display('id');
  73. $form->text('name');
  74. $form->text('type_id');
  75. $form->text('store_id');
  76. $form->text('cover_img');
  77. $form->text('price');
  78. $form->text('original_price');
  79. $form->text('vip_price');
  80. $form->text('on_sale');
  81. $form->text('inventory');
  82. $form->text('content');
  83. $form->text('sort');
  84. $form->text('restrict_num');
  85. $form->text('start_num');
  86. $form->text('is_infinite');
  87. $form->text('good_unit');
  88. $form->text('tags');
  89. $form->text('details_imgs');
  90. $form->text('spec');
  91. $form->display('created_at');
  92. $form->display('updated_at');
  93. });
  94. }
  95. }