clientRepository = $clientRepository; } /** * Xác thực khách hàng và tạo token */ public function authenticateClient(array $credentials): array { if (!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(); $token = $client->createToken('client-token')->plainTextToken; 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 = $client->createToken('client-token')->plainTextToken; return [ 'client' => $client, 'token' => $token, ]; } }