Yii2 get related data using category id

So when creating anything using the CRUD you get a view which will say display data from row 1, say it has a field category id and has the value of 5 how can I get say 5 rows with the same category id of 5 in that single view.

Tried something like this


        $query = ProductItem::find()

        ->limit(10)

        ->where(['category_id' => $this->findModel($id)->category_id]);


        $dataProvider = new ActiveDataProvider([

            'query' => $query

        ]);

UPDATE USED THE FOLLOWING


 $model = $this->findModel($id);


        $query = ProductItem::find()

        ->where(['brand_id' => $model->brand_id])

        ->limit(10);