Created
September 7, 2015 22:42
-
-
Save miguelplazasr/0fd0f9e63c3a2e4122c4 to your computer and use it in GitHub Desktop.
Entity City for Symfony Project
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 AppBundle\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
use Symfony\Component\Validator\Constraints as Assert; | |
use Gedmo\Mapping\Annotation as Gedmo; | |
/** | |
* AppBundle\Entity\City | |
* | |
* @ORM\Table(name="tb_city") | |
* @ORM\Entity(repositoryClass="AppBundle\Entity\CityRepository") | |
*/ | |
class City { | |
/** | |
* @var integer $id | |
* | |
* @ORM\Id | |
* @ORM\Column(type="string") | |
* @ORM\GeneratedValue(strategy="NONE") | |
*/ | |
protected $id; | |
/** | |
* @ORM\Column(type="string") | |
* @Assert\NotBlank() | |
* @Assert\Length( max = "100" ) | |
*/ | |
protected $name; | |
/** | |
* @ORM\ManyToOne(targetEntity="State", inversedBy="cities") | |
* @ORM\JoinColumn(name="state_id", referencedColumnName="id") | |
*/ | |
protected $state; | |
public function __toString() { | |
return $this->name; | |
} | |
/** | |
* Constructor | |
*/ | |
public function __construct() | |
{ | |
$this->customers = new \Doctrine\Common\Collections\ArrayCollection(); | |
} | |
/** | |
* Set id | |
* | |
* @param string $id | |
* @return City | |
*/ | |
public function setId($id) | |
{ | |
$this->id = $id; | |
return $this; | |
} | |
/** | |
* Get id | |
* | |
* @return string | |
*/ | |
public function getId() | |
{ | |
return $this->id; | |
} | |
/** | |
* Set name | |
* | |
* @param string $name | |
* @return City | |
*/ | |
public function setName($name) | |
{ | |
$this->name = $name; | |
return $this; | |
} | |
/** | |
* Get name | |
* | |
* @return string | |
*/ | |
public function getName() | |
{ | |
return $this->name; | |
} | |
/** | |
* Set state | |
* | |
* @param State $state | |
* @return City | |
*/ | |
public function setState(State $state = null) | |
{ | |
$this->state = $state; | |
return $this; | |
} | |
/** | |
* Get state | |
* | |
* @return State | |
*/ | |
public function getState() | |
{ | |
return $this->state; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment