RcstfwltController.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. namespace App\Admin\Controllers\Content;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\LtApppointment;
  5. use Encore\Admin\Controllers\HasResourceActions;
  6. use Encore\Admin\Grid;
  7. use Encore\Admin\Layout\Content;
  8. use Encore\Admin\Show;
  9. //use Encore\Admin\Grid;
  10. class RcstfwltController 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. * Make a grid builder.
  28. *
  29. * @return Grid
  30. */
  31. protected function grid()
  32. {
  33. $grid = new Grid(new LtApppointment);
  34. $grid->model()->orderBy('id', 'DESC');
  35. $status = \Illuminate\Support\Facades\Request::input('status', 99);
  36. if ($status != 99) {
  37. $grid->model()->where('status', '=', $status);
  38. } else {
  39. $grid->model()->where('status', '<', 2);
  40. }
  41. $grid->number('预约号码')->width(200);
  42. $grid->username('真实姓名')->width(150);
  43. $grid->phone('手机')->width(150);
  44. $grid->service('服务事项')->width(300);
  45. $grid->content('说明')->width(600);
  46. $grid->createtime('登记时间')->width(300);
  47. $grid->is_talent('是否认证人才')->width(300)->display(function () {
  48. if ($this->is_talent == 0) {
  49. return '<span style="color: #909399">未认证人才</span>';
  50. } else if ($this->is_talent == 1) {
  51. return '<span style="color: #67C23A">已认证人才</span>';
  52. }
  53. return '';
  54. });
  55. $grid->evaluate('评价')->display(function () {
  56. if ($this->is_talent == 1) {
  57. if (empty($this->evaluate)) {
  58. return '<span style="color: #E6A23C">未评价</span>';
  59. } else {
  60. return '<span style="color: #67C23A">' . $this->evaluate . '</span>';
  61. }
  62. } else {
  63. return '<span style="color: #909399">不需要评价</span>';
  64. }
  65. return '';
  66. });
  67. $grid->actions(function ($actions) {
  68. $actions->disableView(false);
  69. });
  70. $grid->filter(function ($filter) {
  71. $filter->disableIdFilter();
  72. $filter->like('number', '预约单号');
  73. $filter->like('username', '姓名');
  74. $type_option = ['0' => '未认证人才', '1' => '已认证人才', '99' => '全部'];
  75. $filter->where(function ($query) {
  76. if ($this->input != 99) {
  77. $query->where('is_talent', '=', "{$this->input}");
  78. }
  79. }, '是否认证人才', 'is_talent')->radio($type_option);
  80. });
  81. return $grid;
  82. }
  83. public function show($id, Content $content)
  84. {
  85. return $content
  86. ->header('详情')
  87. ->description()
  88. ->body($this->detail($id));
  89. }
  90. protected function detail($id)
  91. {
  92. $show = new Show(LtApppointment::findOrFail($id));
  93. $show->number('预约号码');
  94. $show->username('真实姓名');
  95. $show->phone('手机');
  96. $show->service('服务事项');
  97. $show->content('说明');
  98. $show->createtime('登记时间');
  99. $show->is_talent('是否认证人才')->display(function () {
  100. if ($this->is_talent == 0) {
  101. return '<span style="color: #909399">未认证人才</span>';
  102. } else if ($this->is_talent == 1) {
  103. return '<span style="color: #67C23A">已认证人才</span>';
  104. }
  105. return '';
  106. });
  107. $show->evaluate('评价')->display(function () {
  108. if ($this->is_talent == 1) {
  109. if (empty($this->evaluate)) {
  110. return '<span style="color: #E6A23C">未评价</span>';
  111. } else {
  112. return '<span style="color: #67C23A">' . $this->evaluate . '</span>';
  113. }
  114. } else {
  115. return '<span style="color: #909399">不需要评价</span>';
  116. }
  117. return '';
  118. });
  119. return $show;
  120. }
  121. }