public function actionWall($login){
$user = Yii::$app->user;
$user = User::find()->where(['username' => $login])->one();
if ($user) {
return $user;
}
throw new NotFoundHttpException(Yii::t('app', 'The requested user does not exist.'));
}
public function actionWall($login){
$user = Yii::$app->user;
$user = User::find()->where(['username' => $login])->with('rating')->one();
if ($user) {
return $user;
}
throw new NotFoundHttpException(Yii::t('app', 'The requested user does not exist.'));
public function actionWall($login){
$user = Yii::$app->user;
$user = User::find()->where(['username' => $login])->with(['user', 'person'])->one();
if ($user) {
return $user;
}
throw new NotFoundHttpException(Yii::t('app', 'The requested user does not exist.'));
use api\filters\Auth;
use common\models\HistoryRating;
use common\models\user\Person;
use common\models\user\User;
use Yii;
use yii\data\ActiveDataProvider;
use yii\rest\Controller;
use yii\web\NotFoundHttpException;
use yii\db\ActiveQuery;
class UserController extends Controller
{
public function actionWall($login){
$user = Yii::$app->user;
$user = User::find()->where(['username' => $login])->with(['user', 'person'])->one();
if ($user) {
return $user;
}
throw new NotFoundHttpException(Yii::t('app', 'The requested user does not exist.'));
}
}</code>
with(['user', 'person']) без этого работает нормально , но при этом не могу вывести даанные из связанной таблицы
<code> public function fields()
{
return ['id', 'email', 'username', 'rating'];
}</code>
rating это поле из связанной реляцией таблицы persone
$user = User::find()->where(['username' => $login])->with(['user', 'person'])->one();
как мне правильно сформировать запрос чтоб вывести данные через
fields
UserController.php
<?php
namespace api\modules\v1\controllers;
use api\filters\Auth;
use common\models\HistoryRating;
use common\models\user\Person;
use common\models\user\User;
use Yii;
use yii\data\ActiveDataProvider;
use yii\rest\Controller;
use yii\web\NotFoundHttpException;
use yii\db\ActiveQuery;
class UserController extends Controller
{
public function actionWall($login){
$user = Yii::$app->user;
$user = User::find()->where(['username' => $login])->with(['user', 'person'])->one();
if ($user) {
return $user;
}
throw new NotFoundHttpException(Yii::t('app', 'The requested user does not exist.'));
}
}
<code> public function actionWall($login){
$user = Yii::$app->user;
$user = User::find()->where(['username' => $login])->with([ 'person'])->one();
if ($user) {
return $user;
}
throw new NotFoundHttpException(Yii::t('app', 'The requested user does not exist.'));
public function actionWall($login){
$user = Yii::$app->user;
$user = User::find()->where(['username' => $login])->with([ 'person'])->one();
if ($user) {
return $user;
}
throw new NotFoundHttpException(Yii::t('app', 'The requested user does not exist.'));
}