profil update email verified
This commit is contained in:
@@ -232,4 +232,30 @@ class ProfileController extends Controller
|
||||
return response()->json(['message' => 'File tidak ditemukan'], 404);
|
||||
}
|
||||
}
|
||||
|
||||
public function verify(Request $request, string $id): JSONResponse
|
||||
{
|
||||
if (!Gate::any(['fasilitator'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'email_verified_at' => ['nullable', 'datetime'],
|
||||
]);
|
||||
|
||||
$profile = Profile::findOrFail($id);
|
||||
$user = $profile->user;
|
||||
|
||||
DB::transaction(function () use ($profile, $user, $validated) {
|
||||
$profile->update([
|
||||
'updated_by' => $user->id,
|
||||
]);
|
||||
$user->update([
|
||||
'email_verified_at' => $validated['email_verified_at'],
|
||||
'updated_by' => $user->id,
|
||||
]);
|
||||
});
|
||||
|
||||
return response()->json($profile);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user