Get all model in custom field

My content type has a relation with categories, and these categories have relations with subcategories. I created a plugin to fetch the subcategories using the category ID, but I can’t retrieve the category ID inside my plugin.
Any updates?