clientRepository = $clientRepository; } /** * Xác thực khách hàng và tạo token */ public function authenticateClient(array $credentials): array { if (!$token = Auth::guard('client')->attempt($credentials)) { throw ValidationException::withMessages([ 'email' => ['Thông tin đăng nhập không chính xác.'], ]); } $client = Auth::guard('client')->user(); return [ 'client' => $client, 'token' => $token, ]; } /** * Đăng ký khách hàng mới và tạo token */ public function registerClient(array $data): array { $client = $this->clientRepository->create([ 'fullname' => $data['fullname'], 'phone' => $data['phone'], 'email' => $data['email'], 'password' => bcrypt($data['password']), ]); $token = JWTAuth::fromUser($client); return [ 'client' => $client, 'token' => $token, ]; } }