How to get a Super Table relation in PHP? The following code works great in a template.

{% set priceProduct = currentUser.priceTable.relatedTo({    
    targetElement: product.id,
    field: 'product'
}).one() %}

{{ priceProduct.price }}


Where priceTable is a Super Table, product.id is from an entry element (we're in loop).

'product' is an entry field in the Super Table row and 'price' is a plaintext field in the Super Table row.

How might we go about replicating this functionality in a plugin?

Craft Pro 3.0.29

Super Table 2.0.11
$element = Craft::$app-&gt;getUser()-&gt;getIdentity()-&gt;priceTable-&gt;relatedTo([
    'targetElement' =&gt; $product-&gt;id,
    'field' =&gt; 'product'
])-&gt;one()


But to be honest your code in Twig should not work as expected since you only grab the query and modify it. Your output is your search criteria, not the value of an element.