| xqd
@@ -80,6 +80,19 @@ class ProjectUserRoleController extends BaseController
|
|
|
return back()->withErrors($validator)->withInput();
|
|
|
}
|
|
|
$data = $request->input('data');
|
|
|
+ //判断是否一个项目里有同样的用户,如果有的话就替换掉原来的职位
|
|
|
+ if (!empty($data['project_id'])&&!empty($data['project_role_id']))
|
|
|
+ {
|
|
|
+ $project_users = ProjectUser::where('project_id',$data['project_id'])->where('user_id',$data['user_id'])->get();
|
|
|
+ if (count($project_users)!=0)
|
|
|
+ {
|
|
|
+ $res = ProjectUser::where('project_id',$data['project_id'])
|
|
|
+ ->where('user_id',$data['user_id'])
|
|
|
+ ->update(['project_role_id'=>$data['project_role_id']]);
|
|
|
+ if(empty($res)) return back()->withErrors(['sg_error_info' => '更新失败']);
|
|
|
+ return redirect($this->pre_uri . 'create')->with(['sg_success_info' => '更新成功']);
|
|
|
+ }
|
|
|
+ }
|
|
|
$res = $this->model->create($data);
|
|
|
if(empty($res)) return back()->withErrors(['sg_error_info' => '保存失败']);
|
|
|
return redirect($this->pre_uri . 'create')->with(['sg_success_info' => '创建成功']);
|