Some reason I can’t get my relations to work anymore.
I create a new Log model instance, set the $log->user_id to something, and then try to access the user with $this->user, and it doesn’t work. Here’s my code:
<?php
public function relations() {
return array(
'user' => array(self::BELONGS_TO, 'User', 'user_id', 'alias'=>'user'),
);
}
protected function beforeSave() {
//at this point, $this->user_id is set to something appropriate, i verified this.
$this->challenge_id = $this->user->client->challenge_id; //throws error: $this->user is a non-object
return parent::beforeSave();
}