188 lines
3.5 KiB
PHP
188 lines
3.5 KiB
PHP
<?php
|
|
namespace Cadoles\CoreBundle\Entity;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
/**
|
|
* @ORM\Entity
|
|
* @ORM\Table(name="city")
|
|
* @ORM\HasLifecycleCallbacks()
|
|
*
|
|
* @UniqueEntity(fields="code", message="Une commune existe déjà avec ce code")
|
|
*/
|
|
class City
|
|
{
|
|
/**
|
|
* @ORM\Column(type="integer")
|
|
* @ORM\Id
|
|
* @ORM\GeneratedValue(strategy="AUTO")
|
|
*/
|
|
private $id;
|
|
|
|
/**
|
|
* @ORM\Column(type="string", length=20, unique=true)
|
|
*/
|
|
private $code;
|
|
|
|
/**
|
|
* @ORM\Column(type="string", length=250)
|
|
*/
|
|
private $label;
|
|
|
|
/**
|
|
* @var ArrayCollection $users
|
|
* @var User
|
|
*
|
|
* @ORM\OneToMany(targetEntity="User", mappedBy="birthplace")
|
|
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
|
|
*/
|
|
private $users;
|
|
|
|
/**
|
|
* @var ArrayCollection $registrations
|
|
* @var User
|
|
*
|
|
* @ORM\OneToMany(targetEntity="Registration", mappedBy="birthplace")
|
|
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
|
|
*/
|
|
private $registrations;
|
|
|
|
/**
|
|
* Constructor
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->users = new \Doctrine\Common\Collections\ArrayCollection();
|
|
}
|
|
|
|
/**
|
|
* Get id
|
|
*
|
|
* @return integer
|
|
*/
|
|
public function getId()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
/**
|
|
* Set code
|
|
*
|
|
* @param string $code
|
|
*
|
|
* @return City
|
|
*/
|
|
public function setCode($code)
|
|
{
|
|
$this->code = $code;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get code
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getCode()
|
|
{
|
|
return $this->code;
|
|
}
|
|
|
|
/**
|
|
* Set label
|
|
*
|
|
* @param string $label
|
|
*
|
|
* @return City
|
|
*/
|
|
public function setLabel($label)
|
|
{
|
|
$this->label = $label;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get label
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getLabel()
|
|
{
|
|
return $this->label;
|
|
}
|
|
|
|
/**
|
|
* Add user
|
|
*
|
|
* @param \Cadoles\CoreBundle\Entity\User $user
|
|
*
|
|
* @return City
|
|
*/
|
|
public function addUser(\Cadoles\CoreBundle\Entity\User $user)
|
|
{
|
|
$this->users[] = $user;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Remove user
|
|
*
|
|
* @param \Cadoles\CoreBundle\Entity\User $user
|
|
*/
|
|
public function removeUser(\Cadoles\CoreBundle\Entity\User $user)
|
|
{
|
|
$this->users->removeElement($user);
|
|
}
|
|
|
|
/**
|
|
* Get users
|
|
*
|
|
* @return \Doctrine\Common\Collections\Collection
|
|
*/
|
|
public function getUsers()
|
|
{
|
|
return $this->users;
|
|
}
|
|
|
|
/**
|
|
* Add registration
|
|
*
|
|
* @param \Cadoles\CoreBundle\Entity\Registration $registration
|
|
*
|
|
* @return City
|
|
*/
|
|
public function addRegistration(\Cadoles\CoreBundle\Entity\Registration $registration)
|
|
{
|
|
$this->registrations[] = $registration;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Remove registration
|
|
*
|
|
* @param \Cadoles\CoreBundle\Entity\Registration $registration
|
|
*/
|
|
public function removeRegistration(\Cadoles\CoreBundle\Entity\Registration $registration)
|
|
{
|
|
$this->registrations->removeElement($registration);
|
|
}
|
|
|
|
/**
|
|
* Get registrations
|
|
*
|
|
* @return \Doctrine\Common\Collections\Collection
|
|
*/
|
|
public function getRegistrations()
|
|
{
|
|
return $this->registrations;
|
|
}
|
|
}
|