|
|
|
@ -19,7 +19,7 @@ class HumanResourceController extends Controller
|
|
|
|
|
$this->validate($request, [ |
|
|
|
|
'role_id' => 'required', |
|
|
|
|
'name' => 'required', |
|
|
|
|
'ktp_number' => 'required|numeric|unique:m_users,ktp_number', |
|
|
|
|
'ktp_number' => 'required|string|unique:m_users,ktp_number', |
|
|
|
|
'employee_type' => 'required', |
|
|
|
|
'company_id' => 'required' |
|
|
|
|
]); |
|
|
|
@ -44,7 +44,7 @@ class HumanResourceController extends Controller
|
|
|
|
|
$this->validate($request, [ |
|
|
|
|
'role_id' => 'required', |
|
|
|
|
'name' => 'required', |
|
|
|
|
'ktp_number' => 'required|numeric|unique:m_users,ktp_number', |
|
|
|
|
'ktp_number' => 'required|string|unique:m_users,ktp_number', |
|
|
|
|
'employee_type' => 'required', |
|
|
|
|
'company_id' => 'required', |
|
|
|
|
'username' => 'required', |
|
|
|
@ -60,7 +60,7 @@ class HumanResourceController extends Controller
|
|
|
|
|
$result = HumanResource::create($data); |
|
|
|
|
|
|
|
|
|
if ($result) { |
|
|
|
|
$this->sendEmail($request->email, $data['password']); |
|
|
|
|
$this->sendEmail($request->email, $request->password); |
|
|
|
|
return response()->json(['status' => 'success', 'message' => 'Human Resource Pool successfull created', 'code' => 200]); |
|
|
|
|
} else { |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Human Resource Pool failed created', 'code' => 400]); |
|
|
|
@ -91,7 +91,7 @@ class HumanResourceController extends Controller
|
|
|
|
|
} |
|
|
|
|
$humanresource = HumanResource::find($id); |
|
|
|
|
|
|
|
|
|
$request->ktp_number !== $humanresource['ktp_number'] ? $this->validate($request,['ktp_number'=>'unique:m_users,ktp_number|numeric']) : ''; |
|
|
|
|
$request->ktp_number !== $humanresource['ktp_number'] ? $this->validate($request,['ktp_number'=>'unique:m_users,ktp_number|string']) : ''; |
|
|
|
|
$request->email !== $humanresource['email'] ? $this->validate($request,['email'=>'unique:m_users,email|email']) : ''; |
|
|
|
|
$request->password ? $this->validate($request,['password'=>'required|min:8']) : ''; |
|
|
|
|
|
|
|
|
@ -230,32 +230,28 @@ class HumanResourceController extends Controller
|
|
|
|
|
Artisan::call('sync:integration-human-resources'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function sendEmail($email, $hashPassword) |
|
|
|
|
public function sendEmail($email, $password) |
|
|
|
|
{ |
|
|
|
|
$hashed = $hashPassword; |
|
|
|
|
$user = User::select('email', 'name')->where('email', $email)->first(); |
|
|
|
|
|
|
|
|
|
$user = User::select('email', 'name', 'username')->where('email', $email)->first(); |
|
|
|
|
if (!$user) { |
|
|
|
|
return response()->json(['status' => 'error', 'message' => 'e-mail not found '], 400); |
|
|
|
|
} else { |
|
|
|
|
$this->reqHttpCurl($email, $hashed, $user->name); |
|
|
|
|
// if (User::where('email', $email)->update(['password'=> md5($hashed)])) |
|
|
|
|
// return response()->json(['status' => 'success', 'code'=>200, 'message' => 'Password already sent to mail'], 200); |
|
|
|
|
|
|
|
|
|
$this->reqHttpCurl($email, $password, $user->username, $user->name); |
|
|
|
|
return response()->json(['status' => 'error', 'code'=>400, 'message' => 'e-mail not found '], 400); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function reqHttpCurl($email, $password, $username) |
|
|
|
|
private function reqHttpCurl($email, $password, $username, $name) |
|
|
|
|
{ |
|
|
|
|
$postData = [ |
|
|
|
|
"to" => $email, |
|
|
|
|
"name" => $name, |
|
|
|
|
"username" => $username, |
|
|
|
|
"password" => $password, |
|
|
|
|
"name" => $username, |
|
|
|
|
"from" => "app.integrasia@integrasiautama.com", |
|
|
|
|
"alias_from" => "ADW", |
|
|
|
|
"subject" => "Informasi Akun", |
|
|
|
|
"body" => "informasi-akun-adw" |
|
|
|
|
"alias_from" => "OSPRO", |
|
|
|
|
"subject" => "Registration OSPRO", |
|
|
|
|
"body" => "registration-ospro" |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
$curl = curl_init(); |
|
|
|
|