mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-19 00:34:24 +00:00
70 lines
1.3 KiB
PHP
70 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Chill\PersonBundle\Entity\Household;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Chill\MainBundle\Entity\Address;
|
|
|
|
/**
|
|
* @ORM\Entity
|
|
*/
|
|
class Household
|
|
{
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\GeneratedValue
|
|
* @ORM\Column(type="integer")
|
|
*/
|
|
private $id;
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
/**
|
|
* Addresses
|
|
* @var Collection
|
|
*
|
|
* @ORM\ManyToMany(
|
|
* targetEntity="Chill\MainBundle\Entity\Address",
|
|
* cascade={"persist", "remove", "merge", "detach"})
|
|
* @ORM\JoinTable(name="chill_person_household_to_addresses")
|
|
* @ORM\OrderBy({"validFrom" = "DESC"})
|
|
*/
|
|
private $addresses;
|
|
|
|
|
|
/**
|
|
* @param Address $address
|
|
* @return $this
|
|
*/
|
|
public function addAddress(Address $address)
|
|
{
|
|
$this->addresses[] = $address;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @param Address $address
|
|
*/
|
|
public function removeAddress(Address $address)
|
|
{
|
|
$this->addresses->removeElement($address);
|
|
}
|
|
|
|
/**
|
|
* By default, the addresses are ordered by date, descending (the most
|
|
* recent first)
|
|
*
|
|
* @return \Chill\MainBundle\Entity\Address[]
|
|
*/
|
|
public function getAddresses()
|
|
{
|
|
return $this->addresses;
|
|
}
|
|
|
|
}
|