BuyHouseRsController.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <?php
  2. namespace App\Admin\Controllers\Content;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\TalentHouse;
  5. use App\Models\TalentHouseApply;
  6. use Encore\Admin\Controllers\HasResourceActions;
  7. use Encore\Admin\Grid;
  8. use Encore\Admin\Layout\Content;
  9. use Illuminate\Http\Request;
  10. class BuyHouseRsController extends Controller
  11. {
  12. use HasResourceActions;
  13. private $status = ['未知', '待审核', '审核通过', '审核不通过'];
  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_rs')->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 TalentHouseApply());
  36. $grid->model()->with('house')->orderBy('rs_check_status', 'ASC');
  37. $status_text = $this->status;
  38. $grid->id('ID');
  39. $grid->name('姓名');
  40. $grid->mobile('联系电话');
  41. $grid->talent_level('人才层次');
  42. $grid->column('房源')->display(function () {
  43. return $this->house->name;
  44. });
  45. $grid->rs_check_status('状态')->display(function () use ($status_text) {
  46. return $status_text[$this->rs_check_status];
  47. });
  48. $grid->rs_check_comment('备注');
  49. $grid->actions(function ($actions) {
  50. if ($actions->row['rs_check_status'] == 1) {
  51. $actions->append("<button class='btn btn-primary btn-xs applyaudit' data-code=" . $actions->row['id'] . ">审核</button>");
  52. }
  53. $actions->append("&nbsp;<button class='btn btn-primary btn-xs detail' id=" . $actions->row['id'] . ">详情</button>");
  54. });
  55. $grid->filter(function ($filter) {
  56. $filter->disableIdFilter();
  57. $filter->equal('house_id', '房源')->select(TalentHouse::all()->pluck('name', 'id'));
  58. $status_option = ['全部', '待审核', '审核通过', '审核不通过'];
  59. $filter->where(function ($query) {
  60. if ($this->input > 0) {
  61. $query->where('status', '=', $this->input);
  62. }
  63. }, '状态', 'status')->radio($status_option);
  64. });
  65. return $grid;
  66. }
  67. /**
  68. * 审核
  69. */
  70. public function audit(Request $request)
  71. {
  72. $id = $request->id;
  73. $status = $request->status;
  74. $reason = $request->reason;
  75. $url = empty($request->url) ? '/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/content/buy_house_rs' : $request->url;
  76. if (empty($id)) {
  77. admin_toastr('数据异常', 'error');
  78. return redirect('/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/content/buy_house_rs');
  79. }
  80. $result = TalentHouseApply::where('id', '=', $id)
  81. ->update([
  82. 'rs_check_status' => $status,
  83. 'rs_check_comment' => $reason,
  84. 'rs_check_time' => date('Y-m-d H:i:s'),
  85. ]);
  86. if ($result) {
  87. admin_toastr('审核成功', 'success');
  88. } else {
  89. admin_toastr('该信息不存在或已审核', 'error');
  90. }
  91. return redirect($url);
  92. }
  93. /**
  94. * 详情
  95. */
  96. public function detail(Request $request)
  97. {
  98. $id = $request->id;
  99. $info = TalentHouseApply::find($id);;
  100. $info->family = json_decode($info->family);
  101. $info->marry_text = $this->marry[$info->marry];
  102. //layer相册层
  103. $photos = [
  104. 'certificates' => [],
  105. 'marry_prove' => [],
  106. 'household_register' => [],
  107. 'work_prove' => [],
  108. ];
  109. if (!empty(json_decode($info->certificates))) {
  110. $info->certificates = json_decode($info->certificates);
  111. $photo_data = [];
  112. foreach ($info->certificates as $k => $v) {
  113. $photo_data[] = [
  114. 'alt' => $v->name,
  115. 'pid' => $v->uid,
  116. 'src' => $v->response->path,
  117. ];
  118. }
  119. $photos['certificates'] = [
  120. 'title' => '证件信息',
  121. 'id' => 1,
  122. 'start' => 0,
  123. 'data' => $photo_data,
  124. ];
  125. } else {
  126. $info->certificates = [];
  127. }
  128. if (!empty(json_decode($info->marry_prove))) {
  129. $info->marry_prove = json_decode($info->marry_prove);
  130. $photo_data = [];
  131. foreach ($info->marry_prove as $k => $v) {
  132. $photo_data[] = [
  133. 'alt' => $v->name,
  134. 'pid' => $v->uid,
  135. 'src' => $v->response->path,
  136. ];
  137. }
  138. $photos['marry_prove'] = [
  139. 'title' => '婚姻证明',
  140. 'id' => 1,
  141. 'start' => 0,
  142. 'data' => $photo_data,
  143. ];
  144. } else {
  145. $info->marry_prove = [];
  146. }
  147. if (!empty(json_decode($info->household_register))) {
  148. $info->household_register = json_decode($info->household_register);
  149. $photo_data = [];
  150. foreach ($info->household_register as $k => $v) {
  151. $photo_data[] = [
  152. 'alt' => $v->name,
  153. 'pid' => $v->uid,
  154. 'src' => $v->response->path,
  155. ];
  156. }
  157. $photos['household_register'] = [
  158. 'title' => '户口本',
  159. 'id' => 1,
  160. 'start' => 0,
  161. 'data' => $photo_data,
  162. ];
  163. } else {
  164. $info->household_register = [];
  165. }
  166. if (!empty(json_decode($info->work_prove))) {
  167. $info->work_prove = json_decode($info->work_prove);
  168. $photo_data = [];
  169. foreach ($info->work_prove as $k => $v) {
  170. $photo_data[] = [
  171. 'alt' => $v->name,
  172. 'pid' => $v->uid,
  173. 'src' => $v->response->path,
  174. ];
  175. }
  176. $photos['work_prove'] = [
  177. 'title' => '在职证明',
  178. 'id' => 1,
  179. 'start' => 0,
  180. 'data' => $photo_data,
  181. ];
  182. } else {
  183. $info->work_prove = [];
  184. }
  185. $html = view('admin.ajax.buy_house_detail')->with(['info' => $info, 'photos' => $photos])->render();
  186. return response()->json(['code' => 1, 'data' => $html]);
  187. }
  188. }