LookJobController.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\JobList;
  4. use App\Models\LookJob;
  5. use Carbon\Carbon;
  6. use Illuminate\Http\Request;
  7. use Illuminate\Support\Facades\Auth;
  8. use Illuminate\Support\Facades\Validator;
  9. class LookJobController extends Controller
  10. {
  11. /**获取个人找活信息列表**/
  12. public function GetUserInfoList(Request $request){
  13. $page_index=$request->input('page_index');
  14. $page_size=$request->input('page_size');
  15. $user_id=Auth::user()->id;
  16. return $this->success(LookJob::info($user_id,$page_index,$page_size));
  17. }
  18. /**获取找活列表信息**/
  19. public function GetLookJobList(Request $request){
  20. $page_index=$request->input('page_index');
  21. $page_size=$request->input('page_size');
  22. $status=true;
  23. if (!Auth::check()){
  24. $status=false;
  25. }
  26. $classify_pid=$request->input('classify_pid');
  27. $classify_id=$request->input('classify_id');
  28. $province=$request->input('province');
  29. $city=$request->input('city');
  30. $team_label=$request->input('team_label');
  31. return $this->success(LookJob::GetJobList($page_index,$page_size,$status,$classify_pid,$classify_id,$province,$city,$team_label));
  32. }
  33. public function GetLookJobDetail(Request $request){
  34. $id=$request->input('id');
  35. $status=true;
  36. if (!Auth::check()){
  37. $status=false;
  38. }
  39. return $this->success(LookJob::GetLookJobDetail($id,$status));
  40. }
  41. /**新增找活信息***/
  42. public function AddUpdateInfo(Request $request){
  43. $data=$request->all();
  44. $rules=[
  45. 'classify_id' => 'required',//所属分类
  46. 'mobile' => 'required',//联系电话
  47. 'province' => 'required',
  48. 'city' => 'required',
  49. 'area' => 'required',//招工地址
  50. 'address' => 'required',//招工地址
  51. 'username' => 'required|max:20',//联系人
  52. 'description' => 'required|max:500',//项目简介
  53. // 'longitude' => 'required',//纬度
  54. // 'latitude' => 'required',//经度
  55. 'work_time' => 'required',//工龄
  56. 'team_label' => 'required',//人员构成
  57. 'nation' => 'required',//民族
  58. 'sex' => 'required',//性别
  59. 'datetime' => 'required',//出生日期
  60. ];
  61. $messages=[
  62. 'required'=>':attribute 是必填项!',
  63. 'max'=>':attribute 超过最大值'
  64. ];
  65. $validator = Validator::make($data, $rules, $messages);
  66. if($validator->fails()){
  67. return $this->fail(['400013',$validator->errors()->first()]);
  68. }
  69. if ($request->has('id')){
  70. LookJob::updateInfo($data);
  71. return $this->success();
  72. }
  73. $data['user_id']=Auth::user()->id;
  74. $data['created_at']=Carbon::now();
  75. $data['updated_at']=Carbon::now();
  76. LookJob::add($data);
  77. return $this->success();
  78. }
  79. /**点击更新招满、进行时的装态**/
  80. public function UpdateStatus(Request $request){
  81. $id=$request->input('id');
  82. $status=$request->input('status');
  83. LookJob::updateStatus($id,$status);
  84. return $this->success();
  85. }
  86. /**删除招找活*/
  87. public function DelLookJobInfo(Request $request){
  88. $id=$request->input('id');
  89. LookJob::DelJobInfo($id);
  90. return $this->success();
  91. }
  92. }