Is class like that gonna work ? Can i normally access only userId by getUserId() and getUser() will get related User model ?
class SomeClass extends Model
{
protected $id;
protected $userId;
protected $user;
public function initialize()
{
$this->belongsTo('userId','User','id',array('alias'=>'user'));
}
public function getUserId()
{
return $this->userId;
}
public function getUser()
{
return $this->getRelated('user');
}
}
Is that gonna work without any problems ? Sometimes i just only need user id, dont need to select whole related model.