ProductSkuController.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\ProductSku;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class ProductSkuController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new ProductSku(), function (Grid $grid) {
  18. $grid->column('id')->sortable();
  19. $grid->column('product_id');
  20. $grid->column('name');
  21. $grid->column('cover_img');
  22. $grid->column('origin_price');
  23. $grid->column('sale_price');
  24. $grid->column('created_at');
  25. $grid->column('updated_at')->sortable();
  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 ProductSku(), function (Show $show) {
  41. $show->field('id');
  42. $show->field('product_id');
  43. $show->field('name');
  44. $show->field('cover_img');
  45. $show->field('origin_price');
  46. $show->field('sale_price');
  47. $show->field('created_at');
  48. $show->field('updated_at');
  49. });
  50. }
  51. /**
  52. * Make a form builder.
  53. *
  54. * @return Form
  55. */
  56. protected function form()
  57. {
  58. return Form::make(new ProductSku(), function (Form $form) {
  59. $form->display('id');
  60. $form->text('product_id');
  61. $form->text('name');
  62. $form->text('cover_img');
  63. $form->text('origin_price');
  64. $form->text('sale_price');
  65. $form->display('created_at');
  66. $form->display('updated_at');
  67. });
  68. }
  69. }