DistProductImageController.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace App\Distributor\Controllers;
  3. use App\Distributor\Repositories\DistProductImage;
  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 DistProductImageController extends AdminDistController
  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 DistProductImage(), function (Grid $grid) {
  31. $grid->column('id')->sortable();
  32. $grid->column('image_url');
  33. $grid->column('product_id');
  34. $grid->column('order');
  35. $grid->column('created_at');
  36. $grid->column('updated_at')->sortable();
  37. $grid->filter(function (Grid\Filter $filter) {
  38. $filter->equal('id');
  39. });
  40. });
  41. }
  42. /**
  43. * Make a show builder.
  44. *
  45. * @param mixed $id
  46. *
  47. * @return Show
  48. */
  49. protected function detail($id)
  50. {
  51. return Show::make($id, new DistProductImage(), function (Show $show) {
  52. $show->field('id');
  53. $show->field('image_url');
  54. $show->field('product_id');
  55. $show->field('order');
  56. $show->field('created_at');
  57. $show->field('updated_at');
  58. });
  59. }
  60. /**
  61. * Make a form builder.
  62. *
  63. * @return Form
  64. */
  65. protected function form()
  66. {
  67. return Form::make(new DistProductImage(), function (Form $form) {
  68. $form->display('id');
  69. $form->text('image_url');
  70. $form->text('product_id');
  71. $form->text('order');
  72. $form->display('created_at');
  73. $form->display('updated_at');
  74. });
  75. }
  76. }