get biodata

parent 813c8626
<?php
namespace App\Http\Controllers;
use App\Models\Biodata;
use Exception;
use Illuminate\Http\Request;
class GetDataController extends Controller
{
public function getBiodata(Request $request)
{
try {
$biodata = Biodata::query()->where('nidn', $request->nidn)->first();
return response()->json($biodata);
} catch (Exception $ex) {
return response('Not Found', 404);
}
}
}
......@@ -29,6 +29,7 @@ class User extends Authenticatable
'name',
'email',
'password',
'email_verified_at',
];
/**
......
......@@ -35,7 +35,7 @@ class BiodataRepository
$data['email'] = $auth[0]->email;
$data['name'] = $isdm[0]->nama;
$data['nip'] = $isdm[0]->nip;
$data['nidn'] = $isdm[0]->nidn ? $isdm[0]->nip : null;
$data['nidn'] = $isdm[0]->nidn ? $isdm[0]->nidn : $isdm[0]->nip;
$data['fakultas'] = $isdm[0]->namahomebase;
$data['prodi'] = $isdm[0]->namasatker;
......
......@@ -4,6 +4,7 @@ namespace App\Repositories;
use App\Models\User;
use Auth;
use Carbon\Carbon;
use Illuminate\Support\Str;
class UsersRepository
......@@ -79,6 +80,7 @@ class UsersRepository
{
$data['id'] = $id;
$data['password'] = bcrypt($data['nip'].'s3cr3t5');
$data['email_verified_at'] = Carbon::now();
return $this->model->create($data);
}
......
<?php
use App\Http\Controllers\Authentication\LoginController;
use App\Http\Controllers\GetDataController;
use App\Http\Controllers\User\BukuAjarController;
use App\Http\Controllers\User\FasilitasController;
use App\Http\Controllers\User\KekayaanIntelController;
......@@ -32,6 +33,10 @@ Route::get('/', function () {
Route::get('login', [LoginController::class, 'index'])->name('login');
Route::get('sso/{email}/{sessionid}', [LoginController::class, 'sso']);
Route::middleware(['auth:sanctum', 'verified'])->group(function () {
Route::get('/get-biodata', [GetDataController::class, 'getBiodata']);
});
Route::middleware(['auth:sanctum', 'verified'])->get('/dashboard', function () {
return view('dashboard');
})->name('dashboard');
......
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