In the controller, I have:
public function actionGetItems() { $model = new \app\models\WarehouseItems; $items = $model->find()->with(['user'])->asArray()->all(); return $items; }
In the WarehouseItem model, I have a standard (created by gii) relation expression:
public function getUser() { return $this->hasOne('\dektrium\user\models\User', ['user_id' => 'user_id']); }
How can I control what column data I can get from the user relationship? Currently, I get all the columns that are not very good, as this data is sent to Angular in JSON format. Right now I have a loop through $ items and filer from all the columns that I don't want to send.
yii2 yii2-model
Ljudotina
source share