lemmyAuthService->authenticate($fullInstanceUrl, $username, $password); $platformInstance = PlatformInstance::firstOrCreate([ 'url' => $fullInstanceUrl, 'platform' => $platform, ], [ 'name' => ucfirst($instanceDomain), 'is_active' => true, ]); return PlatformAccount::create([ 'platform' => $platform, 'instance_url' => $fullInstanceUrl, 'username' => $username, 'password' => $password, 'settings' => [ 'display_name' => $authResponse['person_view']['person']['display_name'] ?? null, 'description' => $authResponse['person_view']['person']['bio'] ?? null, 'person_id' => $authResponse['person_view']['person']['id'] ?? null, 'platform_instance_id' => $platformInstance->id, 'api_token' => $authResponse['jwt'] ?? null, ], 'is_active' => true, 'status' => 'active', ]); } }