This commit is contained in:
BakoL2323 2026-03-29 10:05:18 +07:00
parent c1c92d10c3
commit 6f9dde9c38
4 changed files with 98 additions and 0 deletions

View File

@ -213,5 +213,51 @@ public function getUser($id)
] ]
]); ]);
} }
public function getPhoto($id)
{
// Mengambil data user berdasarkan ID
$user = User::find($id);
if ($user && $user->foto) {
// Membuat URL foto yang dapat diakses publik
$photoUrl = url('storage/pegawai/' . $user->foto);
// Mengembalikan response dengan URL foto
return response()->json([
'ok' => true,
'data' => [
'foto_url' => $photoUrl,
]
]);
} else {
return response()->json([
'ok' => false,
'message' => 'Foto tidak ditemukan',
], 404);
}
}
public function getProfile(Request $request)
{
$request->validate([
'user_id' => 'required|numeric|exists:users,id',
]);
// Ambil data pengguna yang sedang terautentikasi
$user = User::find($request->user_id);
if(!$user) {
return response()->json([
'ok' => false,
'message' => 'Pengguna tidak ditemukan'
], 404);
}else{
// Kembalikan data profil termasuk URL foto profil
return response()->json([
'name' => $user->name,
'email' => $user->email,
'url_photo' => url('storage/' . $user->url_photo)
]);
}
}
} }

38
app/Mail/OtpMail.php Normal file
View File

@ -0,0 +1,38 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class OtpMail extends Mailable
{
use Queueable, SerializesModels;
public $otp;
/**
* Create a new message instance.
*
* @param int $otp
*/
public function __construct($otp)
{
$this->otp = $otp;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this
->from(env('MAIL_FROM_ADDRESS', 'rifaulardiyanto@gmail.com'))
->subject('Kode OTP Anda')
->view('emails.otp')
->with(['otp' => $this->otp]);
}
}

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>Kode OTP Anda</title>
</head>
<body>
<p>Halo,</p>
<p>Berikut adalah kode OTP Anda:</p>
<h2>{{ $otp }}</h2>
<p>Kode ini berlaku selama 10 menit.</p>
<p>Terima kasih.</p>
</body>
</html>

View File

@ -71,3 +71,4 @@
//profile //profile
Route::get('/user/{id}', [UserController::class, 'show']); Route::get('/user/{id}', [UserController::class, 'show']);
Route::get('/mobile/riwayat-hari-ini', [UserController::class, 'riwayatHariIni']); Route::get('/mobile/riwayat-hari-ini', [UserController::class, 'riwayatHariIni']);
Route::get('/profile', [UserController::class, 'getProfile']);