How to process Matrix field in controller I am trying to process a text field inside a Matrix field.

In the controller I have this to get posted params:

$element-&gt;setFieldValuesFromRequest($fieldsLocation);


If I want to process a custom text field, I can do it easily with

$result=$element-&gt;getFieldValue('textFieldHandle')


which $result is exactly the text field value.

but if I have this text field in Matrix field, if I do this:

$result=$element-&gt;getFieldValue('matrixFieldHandle')
craft::dd($result)


I get a craft\elements\db\MatrixBlockQuery object which I don't know how I can fetch text value from this object.
You have to loop the Matrix field first, something like this:

foreach($entry-&gt;matrixHandle-&gt;all() as $block) {
   echo $block-&gt;fieldHandle;
}