Esempio n. 1
0
 /**
  * Get user profile data as relation of user table. Ex: User::find(1)->getProfile()->nick
  * @return \Apps\ActiveRecord\Profile
  */
 public function getProfile()
 {
     // lets find profile identity via current user id
     $object = Profile::identity($this->getId());
     // is not exist? Hmmm, lets create it!
     if ($object === null && $this->getId() > 0) {
         $object = new Profile();
         $object->user_id = $this->getId();
         $object->save();
     }
     // return result ;)
     return $object;
 }