123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- namespace App\Http\Controllers;
- use App\Handlers\ImageHandler;
- use App\Http\Requests\CheckAddJonInfoRequest;
- use App\Models\JobList;
- use Carbon\Carbon;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Auth;
- use Illuminate\Support\Facades\Log;
- use Illuminate\Support\Facades\Validator;
- class JobController extends Controller
- {
- /**首页分类列表**/
- public function HomeClassifyList(){
- return $this->success(JobList::GetTopJob());
- }
- /**列表**/
- public function JobList(Request $request){
- $page_index=$request->input('page_index');
- $page_size=$request->input('page_size');
- $status=true;
- if (!Auth::check()){
- $status=false;
- }
- $classify_pid=$request->input('classify_pid');
- $classify_id=$request->input('classify_id');
- $province=$request->input('province');
- $city=$request->input('city');
- return $this->successNewPaginate(JobList::GetJobList($page_index,$page_size,$status,$classify_pid,$classify_id,$province,$city));
- }
- public function GetUserJobList(Request $request){
- $user_id=Auth::user()->id;
- $page_index=$request->input('page_index');
- $page_size=$request->input('page_size');
- return $this->success(JobList::GetUserJobList($page_index,$page_size));
- }
- /**获取详情**/
- public function GetJobDetail(Request $request){
- $id=$request->input('id');
- $status=true;
- if (!Auth::check()){
- $status=false;
- }
- return $this->success(JobList::GetJobDetail($id,$status));
- }
- /*
- * 发布招工信息
- * ***/
- public function AddInfo(Request $request,JobList $jobList){
- $data=$request->all();
- $rules=[
- 'title' => 'required|max:50',//招工名称
- 'classify_id' => 'required',//所属分类
- 'mobile' => 'required',//联系电话
- 'province' => 'required',
- 'city' => 'required',
- 'area' => 'required',//招工地址
- 'address' => 'required',//招工地址
- 'username' => 'required|max:20',//联系人
- 'description' => 'required|max:50',//项目简介
- // 'longitude' => 'required',//纬度
- // 'latitude' => 'required',//经度
- ];
- $messages=[
- 'required'=>':attribute 是必填项!',
- 'max'=>':attribute 超过最大值'
- ];
- $validator = Validator::make($data, $rules, $messages);
- if($validator->fails()){
- return $this->fail(['400013',$validator->errors()->first()]);
- }
- $data['user_id']=Auth::user()->id;
- $data['created_at']=Carbon::now()->toDateTimeString();
- $data['updated_at']=Carbon::now()->toDateTimeString();
- JobList::add($data);
- return $this->success();
- }
- /**上传图片***/
- public function UploadImg(Request $request,ImageHandler $imageHandler){
- $file=$request->file('file');
- if (!$file){
- return $this->fail();
- }
- $path=$imageHandler->save($file,'job',random_int(11,99));
- return $this->success(['url'=>$path['path']]);
- }
- /**点击更新招满、进行时的装态**/
- public function UpdateStatus(Request $request){
- $id=$request->input('id');
- $status=$request->input('status');
- JobList::updateStatus($id,$status);
- return $this->success();
- }
- /**删除招工**/
- public function DelJobInfo(Request $request){
- $id=$request->input('id');
- JobList::DelJobInfo($id);
- return $this->success();
- }
- }
|