feat: 프로필 설정 페이지 추가
- 프로필 정보 수정 (이름, 전화번호) - 비밀번호 변경 기능 - 헤더 드롭다운 메뉴 연결 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
60
app/Http/Controllers/ProfileController.php
Normal file
60
app/Http/Controllers/ProfileController.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\ChangePasswordRequest;
|
||||
use App\Http\Requests\UpdateProfileRequest;
|
||||
use App\Services\ProfileService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ProfileService $profileService
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 프로필 페이지
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
return view('profile.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* 프로필 정보 수정
|
||||
*/
|
||||
public function update(UpdateProfileRequest $request): JsonResponse
|
||||
{
|
||||
$user = auth()->user();
|
||||
$result = $this->profileService->updateProfile($user, $request->validated());
|
||||
|
||||
if ($result) {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => '프로필이 수정되었습니다.',
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => '프로필 수정에 실패했습니다.',
|
||||
], 500);
|
||||
}
|
||||
|
||||
/**
|
||||
* 비밀번호 변경
|
||||
*/
|
||||
public function changePassword(ChangePasswordRequest $request): JsonResponse
|
||||
{
|
||||
$user = auth()->user();
|
||||
$result = $this->profileService->changePassword(
|
||||
$user,
|
||||
$request->current_password,
|
||||
$request->password
|
||||
);
|
||||
|
||||
return response()->json($result, $result['success'] ? 200 : 422);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user