From 6f9dde9c38d50755cbe18e1bf59dff2d8c0ccbf7 Mon Sep 17 00:00:00 2001 From: BakoL2323 <142969559+ardiyanto1234@users.noreply.github.com> Date: Sun, 29 Mar 2026 10:05:18 +0700 Subject: [PATCH] update --- .../Controllers/Mobile/UserController.php | 46 +++++++++++++++++++ app/Mail/OtpMail.php | 38 +++++++++++++++ resources/views/emails/otp.blade.php | 13 ++++++ routes/api.php | 1 + 4 files changed, 98 insertions(+) create mode 100644 app/Mail/OtpMail.php create mode 100644 resources/views/emails/otp.blade.php diff --git a/app/Http/Controllers/Mobile/UserController.php b/app/Http/Controllers/Mobile/UserController.php index e579e3e..ce5bb84 100644 --- a/app/Http/Controllers/Mobile/UserController.php +++ b/app/Http/Controllers/Mobile/UserController.php @@ -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) + ]); + } +} } diff --git a/app/Mail/OtpMail.php b/app/Mail/OtpMail.php new file mode 100644 index 0000000..de9a619 --- /dev/null +++ b/app/Mail/OtpMail.php @@ -0,0 +1,38 @@ +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]); + } +} diff --git a/resources/views/emails/otp.blade.php b/resources/views/emails/otp.blade.php new file mode 100644 index 0000000..a360611 --- /dev/null +++ b/resources/views/emails/otp.blade.php @@ -0,0 +1,13 @@ + + + + Kode OTP Anda + + +

Halo,

+

Berikut adalah kode OTP Anda:

+

{{ $otp }}

+

Kode ini berlaku selama 10 menit.

+

Terima kasih.

+ + diff --git a/routes/api.php b/routes/api.php index 07ea5e9..4f3058d 100644 --- a/routes/api.php +++ b/routes/api.php @@ -71,3 +71,4 @@ //profile Route::get('/user/{id}', [UserController::class, 'show']); Route::get('/mobile/riwayat-hari-ini', [UserController::class, 'riwayatHariIni']); +Route::get('/profile', [UserController::class, 'getProfile']);