BuyHouseCheckLogController.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. namespace App\Admin\Controllers\Content;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\TalentHouseCheckLog;
  5. use Encore\Admin\Controllers\HasResourceActions;
  6. use Encore\Admin\Grid;
  7. use Encore\Admin\Layout\Content;
  8. use Illuminate\Http\Request;
  9. class BuyHouseCheckLogController extends Controller
  10. {
  11. use HasResourceActions;
  12. private $marry = ['未知', '未婚', '已婚', '离异', '丧偶'];
  13. private $status = ['未知', '待审核', '审核通过', '审核不通过'];
  14. /**
  15. * Index interface.
  16. *
  17. * @param Content $content
  18. * @return Content
  19. */
  20. public function index(Content $content)
  21. {
  22. return $content
  23. ->header('审核日志')
  24. ->description(' ')
  25. ->body(view('admin.content.buy_house_check_log')->with(['grid' => $this->grid()]));
  26. }
  27. /**
  28. * Make a grid builder.
  29. *
  30. * @return Grid
  31. */
  32. protected function grid()
  33. {
  34. $grid = new Grid(new TalentHouseCheckLog());
  35. $grid->model()->orderBy('created_at', 'DESC');
  36. $grid->id('ID');
  37. $grid->house_name('房源');
  38. $grid->user_name('用户');
  39. $grid->check_name('审核人');
  40. $status_text = $this->status;
  41. $grid->check_status('审核结果')->display(function () use ($status_text) {
  42. return $status_text[$this->check_status];
  43. });
  44. $grid->check_comment('审核备注');
  45. $grid->created_at('审核时间');
  46. $grid->actions(function ($actions) {
  47. $actions->append("&nbsp;<button class='btn btn-primary btn-xs detail' data-id='{$actions->row['id']}'>数据</button>");
  48. });
  49. $grid->filter(function ($filter) {
  50. $filter->disableIdFilter();
  51. $filter->like('house_name', '房源');
  52. $filter->like('user_name', '用户');
  53. });
  54. return $grid;
  55. }
  56. /**
  57. * 详情
  58. */
  59. public function detail(Request $request)
  60. {
  61. $id = $request->id;
  62. $log = TalentHouseCheckLog::find($id);
  63. $info = json_decode($log->data, true);
  64. $info['family'] = json_decode($info['family']);
  65. $info['marry_text'] = $this->marry[$info['marry']];
  66. //layer相册层
  67. $photos = [
  68. 'certificates' => [],
  69. 'marry_prove' => [],
  70. 'household_register' => [],
  71. 'work_prove' => [],
  72. ];
  73. if (!empty(json_decode($info['certificates']))) {
  74. $info['certificates'] = json_decode($info['certificates']);
  75. $photo_data = [];
  76. foreach ($info['certificates'] as $k => $v) {
  77. $photo_data[] = [
  78. 'alt' => $v->name,
  79. 'pid' => $v->uid,
  80. 'src' => $v->response->path,
  81. ];
  82. }
  83. $photos['certificates'] = [
  84. 'title' => '证件信息',
  85. 'id' => 1,
  86. 'start' => 0,
  87. 'data' => $photo_data,
  88. ];
  89. } else {
  90. $info['certificates'] = [];
  91. }
  92. if (!empty(json_decode($info['marry_prove']))) {
  93. $info['marry_prove'] = json_decode($info['marry_prove']);
  94. $photo_data = [];
  95. foreach ($info['marry_prove'] as $k => $v) {
  96. $photo_data[] = [
  97. 'alt' => $v->name,
  98. 'pid' => $v->uid,
  99. 'src' => $v->response->path,
  100. ];
  101. }
  102. $photos['marry_prove'] = [
  103. 'title' => '婚姻证明',
  104. 'id' => 1,
  105. 'start' => 0,
  106. 'data' => $photo_data,
  107. ];
  108. } else {
  109. $info['marry_prove'] = [];
  110. }
  111. if (!empty(json_decode($info['household_register']))) {
  112. $info['household_register'] = json_decode($info['household_register']);
  113. $photo_data = [];
  114. foreach ($info['household_register'] as $k => $v) {
  115. $photo_data[] = [
  116. 'alt' => $v->name,
  117. 'pid' => $v->uid,
  118. 'src' => $v->response->path,
  119. ];
  120. }
  121. $photos['household_register'] = [
  122. 'title' => '户口本',
  123. 'id' => 1,
  124. 'start' => 0,
  125. 'data' => $photo_data,
  126. ];
  127. } else {
  128. $info['household_register'] = [];
  129. }
  130. if (!empty(json_decode($info['work_prove']))) {
  131. $info['work_prove'] = json_decode($info['work_prove']);
  132. $photo_data = [];
  133. foreach ($info['work_prove'] as $k => $v) {
  134. $photo_data[] = [
  135. 'alt' => $v->name,
  136. 'pid' => $v->uid,
  137. 'src' => $v->response->path,
  138. ];
  139. }
  140. $photos['work_prove'] = [
  141. 'title' => '在职证明',
  142. 'id' => 1,
  143. 'start' => 0,
  144. 'data' => $photo_data,
  145. ];
  146. } else {
  147. $info['work_prove'] = [];
  148. }
  149. $html = view('admin.ajax.buy_house_detail')->with(['info' => $info, 'photos' => $photos])->render();
  150. return response()->json(['code' => 1, 'data' => $html]);
  151. }
  152. }