-
-
Save AaronDDM/8a5b071fa6c9cbda4ae7 to your computer and use it in GitHub Desktop.
Two entities
This file contains 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 | |
namespace myProject\Entity; | |
Class Address { | |
/** | |
* @ORM\Id | |
*/ | |
protected $id; | |
/** | |
* @ORM\Column(type="string") | |
*/ | |
protected $postalCode; | |
public function getPostalCode() | |
{ | |
return $this->postalCode; | |
} | |
public function setPostalCode($postalCode) | |
{ | |
$this->postalCode= $postalCode; | |
} | |
} |
This file contains 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 | |
namespace myProject\Entity; | |
use myProject\Entity\Address; | |
Class User { | |
/** | |
* @ORM\Id | |
*/ | |
protected $id; | |
/** | |
* @ORM\Column(type="string") | |
*/ | |
protected $name; | |
/** | |
* @ORM\OneToOne(targetEntity="Address") | |
* @ORM\JoinColumn(name="id", referencedColumnName="id") | |
*/ | |
protected $address; | |
public function getName() | |
{ | |
return $this->name; | |
} | |
public function setName($name) | |
{ | |
$this->name = $name; | |
} | |
public function getAddress() | |
{ | |
return $this->address; | |
} | |
public function setAddress(Address $address) | |
{ | |
$this->address = $address; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment