VKAPI: add counters field in Users.get

This commit is contained in:
Dmitry Tretyakov 2023-11-22 15:31:26 +07:00 committed by GitHub
parent 93bfe6e886
commit 35bd3ad1e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,7 @@
namespace openvk\VKAPI\Handlers; namespace openvk\VKAPI\Handlers;
use openvk\Web\Models\Entities\{User, Report}; use openvk\Web\Models\Entities\{User, Report};
use openvk\Web\Models\Repositories\Users as UsersRepo; use openvk\Web\Models\Repositories\Users as UsersRepo;
use openvk\Web\Models\Repositories\{Photos, Clubs, Albums, Videos, Notes, Audios};
use openvk\Web\Models\Repositories\Reports; use openvk\Web\Models\Repositories\Reports;
final class Users extends VKAPIRequestHandler final class Users extends VKAPIRequestHandler
@ -180,7 +181,16 @@ final class Users extends VKAPIRequestHandler
break; break;
case "rating": case "rating":
$response[$i]->rating = $usr->getRating(); $response[$i]->rating = $usr->getRating();
break; break;
case "counters":
$response[$i]->counters = (object) [
"friends_count" => $usr->getFriendsCount(),
"photos_count" => (new Albums)->getUserPhotosCount($usr),
"videos_count" => (new Videos)->getUserVideosCount($usr),
"audios_count" => (new Audios)->getUserCollectionSize($usr),
"notes_count" => (new Notes)->getUserNotesCount($usr),
];
break;
} }
} }