UserConsumeRecordController.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. namespace App\Admin\Controllers\Order;
  3. use App\Admin\Actions\Grid\UserRechargeRemark;
  4. use App\Models\UserConsumeRecord;
  5. use Dcat\Admin\Form;
  6. use Dcat\Admin\Grid;
  7. use Dcat\Admin\Show;
  8. use Dcat\Admin\Http\Controllers\AdminController;
  9. class UserConsumeRecordController extends AdminController
  10. {
  11. /**
  12. * Make a grid builder.
  13. *
  14. * @return Grid
  15. */
  16. protected function grid()
  17. {
  18. return Grid::make(UserConsumeRecord::with(['user.info']), function (Grid $grid) {
  19. $grid->column('id')->sortable();
  20. $grid->column('user_id','用户')->display(function () {
  21. $str = "";
  22. $str .= "<div style='margin-right:10px;display: flex;align-items: center'>";
  23. $str .= '<img data-action="preview-img" src="' . $this->user->avatar . '" style="height:50px;width:50px;cursor:pointer;margin-right:10px;" class="img img-thumbnail">';
  24. $str .= '<div>';
  25. $str .= '<p style="margin-bottom: 5px">' . $this->user->nickname . '</p>';
  26. $str .= '<p style="margin-bottom: 0px">' . $this->user->mobile . '</p>';
  27. $str .= "</div>";
  28. $str .= "</div>";
  29. return $str;
  30. });
  31. $grid->column('user.info.platform','所属平台')
  32. ->using(config('global.platform'))
  33. ->label([1=>'primary',2=>'success',3=>'info']);
  34. $grid->column('type')
  35. ->using(config('global.consume_type'))
  36. ->label(['success','info','primary']);
  37. $grid->column('before')->label('info');
  38. $grid->column('change')->display(function (){
  39. return $this->change > 0 ? '+'.$this->change : $this->change;
  40. })->label('danger');
  41. $grid->column('current')->label('success');
  42. $grid->column('remark');
  43. $grid->column('created_at');
  44. $grid->filter(function (Grid\Filter $filter) {
  45. $filter->panel();
  46. $filter->like('user.nickname','昵称')->width(3);
  47. $filter->equal('user.info.platform','所属平台')->select(config('global.platform'))->width(3);
  48. $filter->equal('type','类型')->select(config('global.consume_type'))->width(3);
  49. $filter->between('created_at','创建时间')->datetime()->width(3);
  50. });
  51. $grid->disableCreateButton();
  52. $grid->disableRowSelector();
  53. $grid->disableActions();
  54. });
  55. }
  56. /**
  57. * Make a show builder.
  58. *
  59. * @param mixed $id
  60. *
  61. * @return Show
  62. */
  63. protected function detail($id)
  64. {
  65. return Show::make($id, new UserConsumeRecord(), function (Show $show) {
  66. $show->field('id');
  67. $show->field('user_id');
  68. $show->field('type');
  69. $show->field('before');
  70. $show->field('change');
  71. $show->field('current');
  72. $show->field('remark');
  73. $show->field('order_id');
  74. $show->field('created_at');
  75. $show->field('updated_at');
  76. });
  77. }
  78. /**
  79. * Make a form builder.
  80. *
  81. * @return Form
  82. */
  83. protected function form()
  84. {
  85. return Form::make(new UserConsumeRecord(), function (Form $form) {
  86. $form->display('id');
  87. $form->text('user_id');
  88. $form->text('type');
  89. $form->text('before');
  90. $form->text('change');
  91. $form->text('current');
  92. $form->text('remark');
  93. $form->text('order_id');
  94. $form->display('created_at');
  95. $form->display('updated_at');
  96. });
  97. }
  98. }