|
|
@ -30,6 +30,45 @@ class UserToProyekController extends Controller |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function addMultiple(Request $request){ |
|
|
|
|
|
|
|
$user_IDs = $request->user_id; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data = UserToProyek::where("proyek_id", $request->proyek_id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($data){ |
|
|
|
|
|
|
|
$data->delete(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(is_array($user_IDs) && count($user_IDs) > 0){ |
|
|
|
|
|
|
|
$countRes = 0; |
|
|
|
|
|
|
|
foreach($user_IDs as $item){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$dataInsert = array( |
|
|
|
|
|
|
|
"user_id" => $item, |
|
|
|
|
|
|
|
"proyek_id" => $request->proyek_id, |
|
|
|
|
|
|
|
"created_by" => $this->currentName, |
|
|
|
|
|
|
|
'is_customer'=>true |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result = UserToProyek::create($dataInsert); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($result){ |
|
|
|
|
|
|
|
$countRes++; |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
$countRes--; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if($countRes > 0){ |
|
|
|
|
|
|
|
return response()->json(['status'=>'success' ,'message'=>'Project customer successfull created','code'=>200]); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
return response()->json(['status'=>'success' ,'message'=>'Project customer failed created','code'=>400]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
return response()->json(['status'=>'success' ,'message'=>'Project customer successfull created','code'=>200]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function edit($id){ |
|
|
|
public function edit($id){ |
|
|
|
if(!$id || (int) $id < 0 || $id==""){ |
|
|
|
if(!$id || (int) $id < 0 || $id==""){ |
|
|
|
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
|
|
|
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
|
|
|