Created
November 15, 2016 08:11
-
-
Save ikwattro/f7c0dc12d833c28e937a76a13a2006fc to your computer and use it in GitHub Desktop.
User domain model PHP OGM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use GraphAware\Neo4j\OGM\Annotations as OGM; | |
/** | |
* @OGM\Node(label="User") | |
*/ | |
class User | |
{ | |
/** | |
* @var int | |
* | |
* @OGM\GraphId() | |
*/ | |
protected $id; | |
/** | |
* @var string | |
* | |
* @OGM\Property(type="string") | |
*/ | |
protected $login; | |
/** | |
* @var Profile | |
* | |
* @OGM\Relationship(type="HAS_PROFILE", direction="OUTGOING", targetEntity="Profile", mappedBy="user") | |
*/ | |
protected $profile; | |
/** | |
* @var Account | |
* | |
* @OGM\Relationship(type="HAS_ACCOUNT", direction="OUTGOING", targetEntity="Account", mappedBy="user") | |
* @OGM\Fetch() | |
*/ | |
protected $account; | |
/** | |
* User constructor. | |
* @param string $login | |
*/ | |
public function __construct($login) | |
{ | |
$this->login = $login; | |
$this->profile = new Profile($login.'@graphaware.com'); | |
$this->account = new Account(); | |
} | |
/** | |
* @return int | |
*/ | |
public function getId() | |
{ | |
return $this->id; | |
} | |
/** | |
* @return string | |
*/ | |
public function getLogin() | |
{ | |
return $this->login; | |
} | |
/** | |
* @return Profile | |
*/ | |
public function getProfile() | |
{ | |
return $this->profile; | |
} | |
/** | |
* @return Account | |
*/ | |
public function getAccount() | |
{ | |
return $this->account; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment