BuyHouseLogController.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. namespace App\Admin\Controllers\Content;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\MemberInfo;
  5. use App\Models\TalentHouseLog;
  6. use App\Models\TalentHousePeople;
  7. use Encore\Admin\Controllers\HasResourceActions;
  8. use Encore\Admin\Grid;
  9. use Encore\Admin\Layout\Content;
  10. use Illuminate\Http\Request;
  11. class BuyHouseLogController extends Controller
  12. {
  13. use HasResourceActions;
  14. private $status = ['未知', '待审核', '审核通过', '审核驳回'];
  15. private $marry = ['未知', '未婚', '已婚', '离异', '丧偶'];
  16. /**
  17. * Index interface.
  18. *
  19. * @param Content $content
  20. * @return Content
  21. */
  22. public function index(Content $content)
  23. {
  24. return $content
  25. ->header('申报日志')
  26. ->description(' ')
  27. ->body(view('admin.content.buy_house_log')->with(['grid' => $this->grid()]));
  28. }
  29. /**
  30. * Make a grid builder.
  31. *
  32. * @return Grid
  33. */
  34. protected function grid()
  35. {
  36. $grid = new Grid(new TalentHouseLog());
  37. $grid->model()->orderBy('created_at', 'DESC');
  38. $grid->id('ID');
  39. $grid->house_name('房源');
  40. $grid->user_name('用户');
  41. $grid->created_at('修改时间');
  42. $grid->actions(function ($actions) {
  43. if (!empty($actions->row['old'])) {
  44. $actions->append("&nbsp;<button class='btn btn-primary btn-xs detail' data-id='{$actions->row['id']}' data-type='old'>修改前数据</button>");
  45. }
  46. $actions->append("&nbsp;<button class='btn btn-primary btn-xs detail' data-id='{$actions->row['id']}' data-type='new'>修改后数据</button>");
  47. });
  48. $grid->filter(function ($filter) {
  49. $filter->disableIdFilter();
  50. $filter->like('house_name', '房源');
  51. $filter->like('user_name', '用户');
  52. });
  53. return $grid;
  54. }
  55. /**
  56. * 详情
  57. */
  58. public function detail(Request $request)
  59. {
  60. $id = $request->id;
  61. $type = $request->type;
  62. $log = TalentHouseLog::find($id);
  63. $info = json_decode($log->$type, 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. $info['idcard'] = MemberInfo::where('uid',$info['user_id'])->first();
  150. $html = view('admin.ajax.buy_house_detail')->with(['info' => $info, 'photos' => $photos, 'status' => $this->status])->render();
  151. return response()->json(['code' => 1, 'data' => $html]);
  152. }
  153. }