MemberController.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\UserVip;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use App\Models\User;
  8. use Dcat\Admin\Http\Controllers\AdminController;
  9. class MemberController extends AdminController
  10. {
  11. /**
  12. * Make a grid builder.
  13. *
  14. * @return Grid
  15. */
  16. protected function grid()
  17. {
  18. return Grid::make(new UserVip(), function (Grid $grid) {
  19. $grid->with(['user']);
  20. $grid->column('id')->sortable();
  21. $grid->column('user_id','用户')->display(function () {
  22. return $this->user->nickname;
  23. });
  24. $grid->column('order_fee','购买价格');
  25. $grid->column('created_at','购买时间');
  26. $grid->disableDeleteButton();
  27. $grid->disableCreateButton();
  28. $grid->disableBatchActions();
  29. $grid->disableRowSelector();
  30. $grid->disableActions();
  31. $grid->filter(function (Grid\Filter $filter) {
  32. $filter->equal('user.nickname','用户姓名');
  33. });
  34. });
  35. }
  36. /**
  37. * Make a show builder.
  38. *
  39. * @param mixed $id
  40. *
  41. * @return Show
  42. */
  43. protected function detail($id)
  44. {
  45. return Show::make($id, new UserVip(), function (Show $show) {
  46. $show->field('id');
  47. $show->field('order_id');
  48. $show->field('user_id');
  49. $show->field('prepay_id');
  50. $show->field('serial_number');
  51. $show->field('order_fee');
  52. $show->field('status');
  53. $show->field('created_at');
  54. $show->field('updated_at');
  55. });
  56. }
  57. /**
  58. * Make a form builder.
  59. *
  60. * @return Form
  61. */
  62. protected function form()
  63. {
  64. return Form::make(new UserVip(), function (Form $form) {
  65. $form->display('id');
  66. $form->text('order_id');
  67. $form->text('user_id');
  68. $form->text('prepay_id');
  69. $form->text('serial_number');
  70. $form->text('order_fee');
  71. $form->text('status');
  72. $form->display('created_at');
  73. $form->display('updated_at');
  74. });
  75. }
  76. }