UserMemberController.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Repositories\UserMember;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class UserMemberController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new UserMember(), function (Grid $grid) {
  18. $grid->column('id')->sortable();
  19. $grid->column('title');
  20. $grid->column('type')->display(function (){
  21. if($this->type == 1){
  22. return '连续包月';
  23. }else{
  24. return '一次性支付';
  25. }
  26. })->label();
  27. $grid->column('describe');
  28. $grid->column('money');
  29. $grid->column('month');
  30. $grid->column('updated_at')->sortable();
  31. $grid->disableFilter();
  32. $grid->disableViewButton();
  33. $grid->actions(function (Grid\Displayers\Actions $actions) {
  34. $actions->disableQuickEdit();
  35. $actions->disableView();
  36. });
  37. });
  38. }
  39. /**
  40. * Make a show builder.
  41. *
  42. * @param mixed $id
  43. *
  44. * @return Show
  45. */
  46. protected function detail($id)
  47. {
  48. return Show::make($id, new UserMember(), function (Show $show) {
  49. $show->field('id');
  50. $show->field('title');
  51. $show->field('describe');
  52. $show->field('money');
  53. $show->field('content');
  54. $show->field('created_at');
  55. $show->field('updated_at');
  56. });
  57. }
  58. /**
  59. * Make a form builder.
  60. *
  61. * @return Form
  62. */
  63. protected function form()
  64. {
  65. return Form::make(new UserMember(), function (Form $form) {
  66. $form->display('id')->width(4);
  67. $form->radio('type')->options([
  68. 1 => '连续包月',
  69. 2 => '一次性支付',
  70. ])->default(1);
  71. $form->text('title')->width(4)->required();
  72. $form->text('describe')->width(4);
  73. $form->decimal('money')->width(4)->required();
  74. $form->number('month')->min(1)->width(4)->default(1)->required();
  75. // $form->editor('content');
  76. $form->disableViewButton();
  77. $form->disableDeleteButton();
  78. });
  79. }
  80. }