Commit 557e5d2a by novanbagus

update reviewer otomatis create user

parent c67ada6f
...@@ -14,9 +14,12 @@ use GuzzleHttp\Client; ...@@ -14,9 +14,12 @@ use GuzzleHttp\Client;
use App\Models\Reviewer; use App\Models\Reviewer;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Controllers\Authentication\LoginController;
use App\Traits\LoginTrait;
class ReviewerController extends Controller class ReviewerController extends Controller
{ {
use LoginTrait;
public function index() public function index()
{ {
return view('backend.operator.reviewer.index')->withTitle('Reviewer Seleksi Internal'); return view('backend.operator.reviewer.index')->withTitle('Reviewer Seleksi Internal');
...@@ -106,6 +109,8 @@ class ReviewerController extends Controller ...@@ -106,6 +109,8 @@ class ReviewerController extends Controller
$reqPeriodeId = '9857a29d-521f-413a-b811-94cda7b45897'; $reqPeriodeId = '9857a29d-521f-413a-b811-94cda7b45897';
$reqJenisMonevId = 'ba11c2b5-d65d-4360-9717-98e4fa9b9188'; $reqJenisMonevId = 'ba11c2b5-d65d-4360-9717-98e4fa9b9188';
$result = $this->login_reviewer($request->input('nidn'));
$ada_data = Reviewer::where([ $ada_data = Reviewer::where([
['id_sdm', '=', $request->input('id_sdm')], ['id_sdm', '=', $request->input('id_sdm')],
['periode_id', '=', $reqPeriodeId], ['periode_id', '=', $reqPeriodeId],
......
...@@ -33,7 +33,9 @@ class BiodataRepository ...@@ -33,7 +33,9 @@ class BiodataRepository
$apiRequest = $client->request('GET', 'https://i-sdm.unesa.ac.id/biodataumum/'.trim($auth[0]->userid)); $apiRequest = $client->request('GET', 'https://i-sdm.unesa.ac.id/biodataumum/'.trim($auth[0]->userid));
$isdm = json_decode($apiRequest->getBody()->getContents()); $isdm = json_decode($apiRequest->getBody()->getContents());
$data['email'] = $auth[0]->email; // ubah novan karena ambil email dari isdm saja jangan dari auth;
// $data['email'] = $auth[0]->email;
$data['email'] = $isdm[0]->email;
$data['name'] = $isdm[0]->nama; $data['name'] = $isdm[0]->nama;
$data['noid'] = $isdm[0]->nip; $data['noid'] = $isdm[0]->nip;
if ($isdm[0]->isdosen == 0) { if ($isdm[0]->isdosen == 0) {
......
<?php
namespace App\Traits;
use App\Repositories\Auth\BiodataRepository;
use App\Repositories\Auth\RoleRepository;
use App\Repositories\Auth\UserRepository;
use App\Repositories\UserdetailRepository;
use Illuminate\Support\Str;
trait LoginTrait
{
private $userRepo;
private $roleRepo;
private $biodataRepo;
private $userDetailRepo;
public function __construct(
UserRepository $userRepo,
RoleRepository $roleRepo,
BiodataRepository $biodataRepo,
UserdetailRepository $userDetailRepo
) {
$this->userRepo = $userRepo;
$this->roleRepo = $roleRepo;
$this->biodataRepo = $biodataRepo;
$this->userDetailRepo = $userDetailRepo;
}
public function login_reviewer($nip)
{
$user = $this->userRepo->find(null, $nip, null);
if ($user) {
return $this->getlogin($user->id);
} else {
return $this->getAddReviewer($nip);
}
}
private function getAddReviewer($nip)
{
$id = (string) Str::uuid();
$data = collect([
(object) [
'jenis' => 'P',
'userid' => $nip
]
]);
$biodata = $this->biodataRepo->biodata($data->toArray());
$user = $this->userRepo->storeSso($id, $biodata);
$roles = $this->roleRepo->roles('reviewer');
$this->userDetailRepo->storeSso($user->id, $biodata);
$this->roleRepo->store($user, $roles);
return 'sukses';
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment