data; $data = $request->post(); /** * 通过中间件获取userid */ $userid=$user['id']; $projectid=$data['projectid']; $type=$data['type']; $search_type=$type==1?'registerserve':'recruitingpersonnel'; $res=ProjectDetailed::where('projectid',$projectid)->first(); $Project=Project::where('id',$projectid)->first(); if(ProjectRegister::where('projectid',$projectid)->where('type','=',$type)->count()==$res->$search_type){ return ApiResponse::success(402,[],"当前报名人数已经满员"); } /** * 查询用户是否报名过 */ $issignup=ProjectRegister::where('userid',$userid)->where('projectid',$projectid)->count(); if($issignup==0){ $ProjectRegister=new ProjectRegister(); $ProjectRegister->projectid=$projectid; $ProjectRegister->type=$type; $ProjectRegister->userid=$userid; $ProjectRegister->save(); MessageDao::SendMessage($userid,"系统提醒","您已成功报名 $Project->title "); return ApiResponse::success(200,[],"报名成功"); } return ApiResponse::success(402,$issignup,"您已经报名过了"); } }