BuyHouseLogController.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <?php
  2. namespace App\Admin\Controllers\Content;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\TalentHouseLog;
  5. use App\Models\TalentHousePeople;
  6. use Encore\Admin\Controllers\HasResourceActions;
  7. use Encore\Admin\Grid;
  8. use Encore\Admin\Layout\Content;
  9. use Illuminate\Http\Request;
  10. class BuyHouseLogController extends Controller
  11. {
  12. use HasResourceActions;
  13. private $marry = ['未知', '未婚', '已婚', '离异', '丧偶'];
  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_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 TalentHouseLog());
  35. $grid->model()->orderBy('created_at', 'DESC');
  36. $grid->id('ID');
  37. $grid->house_name('房源');
  38. $grid->user_name('用户');
  39. $grid->created_at('修改时间');
  40. $grid->actions(function ($actions) {
  41. if (!empty($actions->row['old'])) {
  42. $actions->append("&nbsp;<button class='btn btn-primary btn-xs detail' data-id='{$actions->row['id']}' data-type='old'>修改前数据</button>");
  43. }
  44. $actions->append("&nbsp;<button class='btn btn-primary btn-xs detail' data-id='{$actions->row['id']}' data-type='new'>修改后数据</button>");
  45. });
  46. $grid->filter(function ($filter) {
  47. $filter->disableIdFilter();
  48. $filter->like('house_name', '房源');
  49. $filter->like('user_name', '用户');
  50. });
  51. return $grid;
  52. }
  53. /**
  54. * 详情
  55. */
  56. public function detail(Request $request)
  57. {
  58. $id = $request->id;
  59. $type = $request->type;
  60. $log = TalentHouseLog::find($id);
  61. $info = json_decode($log->$type, true);
  62. $info['family'] = json_decode($info['family']);
  63. $info['marry_text'] = $this->marry[$info['marry']];
  64. //layer相册层
  65. $photos = [
  66. 'certificates' => [],
  67. 'marry_prove' => [],
  68. 'household_register' => [],
  69. 'work_prove' => [],
  70. ];
  71. if (!empty(json_decode($info['certificates']))) {
  72. $info['certificates'] = json_decode($info['certificates']);
  73. $photo_data = [];
  74. foreach ($info['certificates'] as $k => $v) {
  75. $photo_data[] = [
  76. 'alt' => $v->name,
  77. 'pid' => $v->uid,
  78. 'src' => $v->response->path,
  79. ];
  80. }
  81. $photos['certificates'] = [
  82. 'title' => '证件信息',
  83. 'id' => 1,
  84. 'start' => 0,
  85. 'data' => $photo_data,
  86. ];
  87. } else {
  88. $info['certificates'] = [];
  89. }
  90. if (!empty(json_decode($info['marry_prove']))) {
  91. $info['marry_prove'] = json_decode($info['marry_prove']);
  92. $photo_data = [];
  93. foreach ($info['marry_prove'] as $k => $v) {
  94. $photo_data[] = [
  95. 'alt' => $v->name,
  96. 'pid' => $v->uid,
  97. 'src' => $v->response->path,
  98. ];
  99. }
  100. $photos['marry_prove'] = [
  101. 'title' => '婚姻证明',
  102. 'id' => 1,
  103. 'start' => 0,
  104. 'data' => $photo_data,
  105. ];
  106. } else {
  107. $info['marry_prove'] = [];
  108. }
  109. if (!empty(json_decode($info['household_register']))) {
  110. $info['household_register'] = json_decode($info['household_register']);
  111. $photo_data = [];
  112. foreach ($info['household_register'] as $k => $v) {
  113. $photo_data[] = [
  114. 'alt' => $v->name,
  115. 'pid' => $v->uid,
  116. 'src' => $v->response->path,
  117. ];
  118. }
  119. $photos['household_register'] = [
  120. 'title' => '户口本',
  121. 'id' => 1,
  122. 'start' => 0,
  123. 'data' => $photo_data,
  124. ];
  125. } else {
  126. $info['household_register'] = [];
  127. }
  128. if (!empty(json_decode($info['work_prove']))) {
  129. $info['work_prove'] = json_decode($info['work_prove']);
  130. $photo_data = [];
  131. foreach ($info['work_prove'] as $k => $v) {
  132. $photo_data[] = [
  133. 'alt' => $v->name,
  134. 'pid' => $v->uid,
  135. 'src' => $v->response->path,
  136. ];
  137. }
  138. $photos['work_prove'] = [
  139. 'title' => '在职证明',
  140. 'id' => 1,
  141. 'start' => 0,
  142. 'data' => $photo_data,
  143. ];
  144. } else {
  145. $info['work_prove'] = [];
  146. }
  147. $html = view('admin.ajax.buy_house_detail')->with(['info' => $info, 'photos' => $photos])->render();
  148. return response()->json(['code' => 1, 'data' => $html]);
  149. }
  150. }