MembersProjectController.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. namespace App\Admin\Controllers\Person;
  3. use App\Models\membersProject;
  4. use App\Http\Controllers\Controller;
  5. use Encore\Admin\Controllers\HasResourceActions;
  6. use Encore\Admin\Form;
  7. use Encore\Admin\Grid;
  8. use Encore\Admin\Layout\Content;
  9. use Encore\Admin\Show;
  10. class MembersProjectController extends Controller
  11. {
  12. use HasResourceActions;
  13. /**
  14. * Index interface.
  15. *
  16. * @param Content $content
  17. * @return Content
  18. */
  19. public function index(Content $content)
  20. {
  21. return $content
  22. ->header('创业项目')
  23. ->description(' ')
  24. ->body($this->grid());
  25. }
  26. /**
  27. * Show interface.
  28. *
  29. * @param mixed $id
  30. * @param Content $content
  31. * @return Content
  32. */
  33. public function show($id, Content $content)
  34. {
  35. return $content
  36. ->header('Detail')
  37. ->description('description')
  38. ->body($this->detail($id));
  39. }
  40. /**
  41. * Edit interface.
  42. *
  43. * @param mixed $id
  44. * @param Content $content
  45. * @return Content
  46. */
  47. public function edit($id, Content $content)
  48. {
  49. return $content
  50. ->header('Edit')
  51. ->description('description')
  52. ->body($this->form()->edit($id));
  53. }
  54. /**
  55. * Create interface.
  56. *
  57. * @param Content $content
  58. * @return Content
  59. */
  60. public function create(Content $content)
  61. {
  62. return $content
  63. ->header('Create')
  64. ->description('description')
  65. ->body($this->form());
  66. }
  67. /**
  68. * Make a grid builder.
  69. *
  70. * @return Grid
  71. */
  72. protected function grid()
  73. {
  74. $grid = new Grid(new membersProject);
  75. $grid->model()->orderBy('id', 'desc');
  76. $grid->project_title('创业项目');
  77. $grid->project_intro('项目介绍');
  78. $grid->link_man('联系人');
  79. $grid->link_phone('联系电话');
  80. $grid->link_email('联系邮箱');
  81. $grid->actions(function ($actions) {
  82. $actions->disableDelete();//屏蔽删除按钮
  83. $actions->disableEdit();//屏蔽编辑按钮
  84. $actions->disableView(false);//屏蔽查看按钮
  85. });
  86. $grid->filter(function ($filter) {
  87. // $filter->equal('id', 'ID');
  88. $filter->like('project_title', '标题');
  89. $filter->like('link_man', '联系人');
  90. $filter->like('link_phone', '联系电话');
  91. $date3 = date('Y-m-d', strtotime("-3 day"));
  92. $date7 = date('Y-m-d', strtotime("-7 day"));
  93. $date30 = date("Y-m-d", strtotime("-1 month"));
  94. $date180 = date("Y-m-d", strtotime("-6 month"));
  95. $date360 = date("Y-m-d", strtotime("-1 year"));
  96. $date_option = array(
  97. '' => '不限',
  98. $date3 => '三天内',
  99. $date7 => '一周内',
  100. $date30 => '一月内',
  101. $date180 => '半年内',
  102. $date360 => '一年内',
  103. );
  104. $filter->where(function ($query) {
  105. $query->where('created_at', '>=', "{$this->input}");
  106. }, '添加时间', 'created_at')->radio($date_option);
  107. });
  108. return $grid;
  109. }
  110. /**
  111. * Make a show builder.
  112. *
  113. * @param mixed $id
  114. * @return Show
  115. */
  116. protected function detail($id)
  117. {
  118. $show = new Show(membersProject::findOrFail($id));
  119. $show->link_man('联系人');
  120. $show->link_phone('联系电话');
  121. $show->link_email('联系邮箱');
  122. $show->link_address('联系地址');
  123. $show->project_title('创业项目');
  124. $show->project_intro('项目介绍');
  125. $show->project_info('创业情况');
  126. $show->project_help('希望获得的帮助');
  127. $show->uid('用户id');
  128. $show->created_at('创建时间');
  129. $show->updated_at('修改时间');
  130. return $show;
  131. }
  132. /**
  133. * Make a form builder.
  134. *
  135. * @return Form
  136. */
  137. protected function form()
  138. {
  139. $form = new Form(new membersProject);
  140. $form->display('ID');
  141. $form->display('Created at');
  142. $form->display('Updated at');
  143. return $form;
  144. }
  145. }