TalentController.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: michaelwu
  5. * Date: 2018/10/31
  6. * Time: 10:02
  7. */
  8. namespace App\Http\Controllers\Mobile\Company;
  9. use App\Http\Controllers\Mobile\MobileBaseController;
  10. use App\Models\CompanyTalent;
  11. use App\Models\CompanyTalentBase;
  12. use App\Models\CompanyTalentNeed;
  13. use App\Models\CompanyTalentSuggest;
  14. use Illuminate\Http\Request;
  15. class TalentController extends MobileBaseController
  16. {
  17. private $_sub_site = '';
  18. public function __construct()
  19. {
  20. if (get_subsite_id() > 0) {
  21. $this->_sub_site = 'jkq.';
  22. }
  23. }
  24. /**
  25. * 人才管理
  26. */
  27. public function index()
  28. {
  29. $company = auth('web-company')->user();
  30. $base = CompanyTalentBase::where('id', $company->id)->first();
  31. if (empty($base)) {
  32. return redirect(route($this->_sub_site . 'mobile.company.talent.base_info'));
  33. }
  34. return view('mobile.app.company.talent.index', ['wap_title' => '人才管理', 'company' => $company, 'base' => $base]);
  35. }
  36. /**
  37. * 企业基础信息
  38. */
  39. public function baseInfo()
  40. {
  41. $company = auth('web-company')->user();
  42. $base = CompanyTalentBase::where('id', $company->id)->first();
  43. if (empty($base)) {
  44. $base = [
  45. 'company_grade' => 1,
  46. 'laboratory_grade' => 1,
  47. ];
  48. }
  49. $data = [
  50. 'wap_title' => '企业基础信息',
  51. 'company' => $company,
  52. 'base' => $base,
  53. 'company_grade' => CompanyTalentBase::$company_grade,
  54. 'laboratory_grade' => CompanyTalentBase::$laboratory_grade,
  55. ];
  56. return view('mobile.app.company.talent.base_info', $data);
  57. }
  58. /**
  59. * 提交基础信息
  60. */
  61. public function baseInfoSave(Request $request)
  62. {
  63. $company = auth('web-company')->user();
  64. $data = $request->all();
  65. foreach ($data as &$v) {
  66. if (empty($v)) {
  67. $v = 0;
  68. }
  69. }
  70. $data['updated_at'] = date('Y-m-d H:i:s');
  71. $base = CompanyTalentBase::where('id', $company->id)->first();
  72. if (empty($base)) {
  73. $data['id'] = $company->id;
  74. CompanyTalentBase::create($data);
  75. } else {
  76. CompanyTalentBase::where('id', $company->id)->update($data);
  77. }
  78. return $this->sendSuccessResponse();
  79. }
  80. /**
  81. * 人才信息
  82. */
  83. public function talentList(Request $request)
  84. {
  85. $company = auth('web-company')->user();
  86. $size = 8;
  87. $rst = CompanyTalent::where('company_id', $company->id)->paginate($size);
  88. if ($request->ajax()) {
  89. if ($rst->lastPage() < $rst->currentPage()) {
  90. return response()->json(['status' => 0]);
  91. }
  92. return response()->json(['status' => 1, 'data' => view('mobile.app.company.talent.ajax_talent_list', ['list' => $rst])->render()]);
  93. }
  94. $mobile_dropload = false;
  95. if ($rst->total() > $size) {
  96. $mobile_dropload = true;
  97. }
  98. $return_data = [
  99. 'list' => $rst,
  100. 'current_url' => \Illuminate\Support\Facades\Request::getRequestUri(),
  101. 'wap_title' => '人才信息列表',
  102. 'mobile_dropload' => $mobile_dropload,
  103. 'back_url' => route('mobile.company.talent.index'),
  104. ];
  105. return view('mobile.app.company.talent.talent_list', $return_data);
  106. }
  107. /**
  108. * 人才删除
  109. */
  110. public function talentDelete(Request $request)
  111. {
  112. $id = $request->input('id');
  113. $res = CompanyTalent::destroy($id);
  114. if ($res) {
  115. return response()->json(['status' => 1, 'msg' => '删除成功']);
  116. } else {
  117. return response()->json(['status' => 0, 'msg' => '网络问题,请刷新重试']);
  118. }
  119. }
  120. /**
  121. * 人才信息
  122. */
  123. public function talentInfo(Request $request)
  124. {
  125. $id = $request->input('id');
  126. $info = [];
  127. if (!empty($id)) {
  128. $info = CompanyTalent::where('id', $id)->first();
  129. }
  130. return view('mobile.app.company.talent.talent_info', ['info' => $info, 'wap_title' => '人才信息']);
  131. }
  132. /**
  133. * 人才信息保存
  134. */
  135. public function talentInfoSave(Request $request)
  136. {
  137. $data = $request->all();
  138. if (empty($data['id'])) {
  139. $company = auth('web-company')->user();
  140. $data['company_id'] = $company->id;
  141. CompanyTalent::create($data);
  142. } else {
  143. CompanyTalent::where('id', $data['id'])->update($data);
  144. }
  145. return $this->sendSuccessResponse();
  146. }
  147. /**
  148. * 意见建议
  149. */
  150. public function talentSuggest()
  151. {
  152. return view('mobile.app.company.talent.talent_suggest', ['wap_title' => '意见建议']);
  153. }
  154. /**
  155. * 意见建议保存
  156. */
  157. public function talentSuggestSave(Request $request)
  158. {
  159. $data = $request->all();
  160. foreach ($data as &$v) {
  161. if (empty($v)) {
  162. $v = '';
  163. }
  164. }
  165. $company = auth('web-company')->user();
  166. $data['company_id'] = $company->id;
  167. CompanyTalentSuggest::create($data);
  168. return $this->sendSuccessResponse();
  169. }
  170. /**
  171. * 人才需求列表
  172. */
  173. public function needList(Request $request)
  174. {
  175. $company = auth('web-company')->user();
  176. $size = 8;
  177. $rst = CompanyTalentNeed::where('company_id', $company->id)->paginate($size);
  178. if ($request->ajax()) {
  179. if ($rst->lastPage() < $rst->currentPage()) {
  180. return response()->json(['status' => 0]);
  181. }
  182. return response()->json(['status' => 1, 'data' => view('mobile.app.company.talent.ajax_need_list', ['list' => $rst])->render()]);
  183. }
  184. $mobile_dropload = false;
  185. if ($rst->total() > $size) {
  186. $mobile_dropload = true;
  187. }
  188. $return_data = [
  189. 'list' => $rst,
  190. 'current_url' => \Illuminate\Support\Facades\Request::getRequestUri(),
  191. 'wap_title' => '人才需求列表',
  192. 'mobile_dropload' => $mobile_dropload,
  193. 'type' => CompanyTalentNeed::$type,
  194. 'back_url' => route('mobile.company.talent.index'),
  195. ];
  196. return view('mobile.app.company.talent.need_list', $return_data);
  197. }
  198. /**
  199. * 删除需求
  200. */
  201. public function needDelete(Request $request)
  202. {
  203. $id = $request->input('id');
  204. $res = CompanyTalentNeed::destroy($id);
  205. if ($res) {
  206. return response()->json(['status' => 1, 'msg' => '删除成功']);
  207. } else {
  208. return response()->json(['status' => 0, 'msg' => '网络问题,请刷新重试']);
  209. }
  210. }
  211. /**
  212. * 需求详情
  213. */
  214. public function needInfo(Request $request)
  215. {
  216. $id = $request->input('id');
  217. $info = ['type' => 1];
  218. if (!empty($id)) {
  219. $info = CompanyTalentNeed::where('id', $id)->first();
  220. }
  221. $rst = [
  222. 'info' => $info,
  223. 'wap_title' => '人才信息',
  224. 'type' => CompanyTalentNeed::$type,
  225. 'cooperation' => CompanyTalentNeed::$cooperation,
  226. 'manager_level' => CompanyTalentNeed::$manager_level,
  227. 'manager_qualification' => CompanyTalentNeed::$manager_qualification,
  228. 'manager_education' => CompanyTalentNeed::$manager_education,
  229. 'technology_level' => CompanyTalentNeed::$technology_level,
  230. 'technology_education' => CompanyTalentNeed::$technology_education,
  231. 'skill_level' => CompanyTalentNeed::$skill_level,
  232. ];
  233. return view('mobile.app.company.talent.need_info', $rst);
  234. }
  235. /**
  236. * 需求提交
  237. */
  238. public function needInfoSave(Request $request)
  239. {
  240. $data = $request->all();
  241. if (empty($data['id'])) {
  242. $company = auth('web-company')->user();
  243. $data['company_id'] = $company->id;
  244. CompanyTalentNeed::create($data);
  245. } else {
  246. CompanyTalentNeed::where('id', $data['id'])->update($data);
  247. }
  248. return $this->sendSuccessResponse();
  249. }
  250. }