1
我有一個搜索模式:Yii2。如何訪問搜索模型中的子查詢字段?
$query = User::find();
$myOrdersQuery = Request::find()
->select('count(*)')
->where([
'user_id' => $clientsIds,
'agent_id' => $this->viewer->id,
]);
$query->addSelect(['my_orders_count' => $myOrdersQuery]);
當我試圖把它打印到GridView控件
[
'attribute' => 'my_orders_count',
'value' => function ($model) {
return $model->my_orders_count;
}
],
它說,獲得未知屬性:共同\型號\用戶:: my_orders_count
請幫忙查看這個字段
@Maxim歡迎您 – scaisEdge