AccountController.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Repositories\Account;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class AccountController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new Account(), function (Grid $grid) {
  18. $grid->column('id')->sortable();
  19. $grid->column('avatar','用户头像')->image(config("filesystems.disks.cosv5.url"), 60, 60);;
  20. $grid->column('username');
  21. $grid->column('coupon')->display(function($v) {
  22. return $v.' <a href="/admin/coupon_records?account_id='.$this->id.'" target="_blank">查看明细</a>';
  23. });
  24. $grid->column('box_record','开盒记录')->display(function($v) {
  25. return '<a href="/admin/box_records?account_id='.$this->id.'" target="_blank">点击查看</a>';
  26. });
  27. $grid->column('paster');
  28. $grid->column('uid','uid')->help("B站用户ID");
  29. $grid->column('created_at');
  30. $grid->column('updated_at')->sortable();
  31. $grid->filter(function (Grid\Filter $filter) {
  32. $filter->panel();
  33. $filter->expand();
  34. $filter->equal('uid','用户UID')->width(2);
  35. $filter->like('name','用户名称')->width(2);
  36. });
  37. $grid->disableCreateButton();
  38. $grid->enableDialogCreate();
  39. $grid->setDialogFormDimensions('40%', '50%');
  40. $grid->withBorder();
  41. $grid->actions(function (Grid\Displayers\Actions $actions) {
  42. $actions->quickEdit(true);
  43. $actions->disableEdit();
  44. $actions->disableView();
  45. });
  46. $grid->tools(function (Grid\Tools $tools) {
  47. $tools->append(new \App\Admin\Actions\Grid\NewUserCouponAction());
  48. });
  49. });
  50. }
  51. /**
  52. * Make a show builder.
  53. *
  54. * @param mixed $id
  55. *
  56. * @return Show
  57. */
  58. protected function detail($id)
  59. {
  60. return Show::make($id, new Account(), function (Show $show) {
  61. $show->field('id');
  62. $show->field('username');
  63. $show->field('coupon');
  64. $show->field('paster');
  65. $show->field('created_at');
  66. $show->field('updated_at');
  67. });
  68. }
  69. /**
  70. * Make a form builder.
  71. *
  72. * @return Form
  73. */
  74. protected function form()
  75. {
  76. return Form::make(new Account(), function (Form $form) {
  77. // $form->display('id');
  78. $form->text('username');
  79. $form->number('coupon');
  80. $form->number('paster');
  81. //
  82. // $form->display('created_at');
  83. // $form->display('updated_at');
  84. });
  85. }
  86. }