BuyHouseLogController.php 5.3 KB

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