So in Profile table I created new field named 'rayon_id' which is FK of my new table Rayon's 'id'
both model had the relationship coded.
In Rayon.php
/**
* @return \yii\db\ActiveQuery
*/
public function getProfiles()
{
return $this->hasMany(Profile::className(), ['rayon_id' => 'id']);
}
and In Profile.php
(Overridden model)
namespace app\models;
use dektrium\user\models\Profile as BaseProfile;
class Profile extends BaseProfile
{
public function getRayon()
{
return $this->hasOne($this->module->modelMap['Rayon'], ['id' => 'rayon_id']);
}
And here my overridden controller AdminController.php
namespace app\controllers\user;
use dektrium\user\controllers\AdminController as BaseAdminController;
use Yii;
use yii\helpers\Url;
use backend\models\Rayon;
class AdminController extends BaseAdminController
{
public function actionUpdateProfile($id)
{
Url::remember('', 'actions-redirect');
$user = $this->findModel($id);
$profile = $user->profile;
$rayon = $profile->rayon;
I got an error while added $rayon = $profile->rayon;
Why am I getting the undefined index?