|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468 |
- <?php
-
- namespace Lc\CaracoleBundle\Model\User;
-
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Gedmo\Mapping\Annotation as Gedmo;
- use Lc\CaracoleBundle\Model\Address\AddressInterface;
- use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
- use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
- use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
- use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
- use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
- use Lc\SovBundle\Model\User\User as SovUserModel;
- use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
- use Lc\SovBundle\Model\Ticket\TicketInterface;
-
- /**
- * @ORM\MappedSuperclass()
- *
- */
- abstract class UserModel extends SovUserModel
- {
- /**
- * @ORM\Column(type="string", length=20, nullable=true)
- */
- protected $phone;
-
- /**
- * @ORM\Column(type="string", length=64, nullable=true)
- */
- protected $behaviorDisplayPrice;
-
- /**
- * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface")
- */
- protected $favoriteMerchant;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Address\AddressInterface", mappedBy="user", cascade={"persist"})
- */
- protected $addresses;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Order\OrderShopInterface", mappedBy="user")
- */
- protected $orders;
-
- /**
- * @ORM\Column(type="string", length=64, nullable=true)
- */
- protected $firstname;
-
- /**
- * @ORM\Column(type="string", length=64, nullable=true)
- */
- protected $lastname;
-
- /**
- * @ORM\Column(type="boolean", nullable=true)
- */
- protected $gender;
-
- /**
- * @ORM\ManyToMany(targetEntity="Lc\SovBundle\Model\Newsletter\NewsletterInterface", inversedBy="users")
- */
- protected $newsletters;
-
-
- /**
- * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilyInterface")
- */
- protected $favoriteProductFamilies;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\User\UserPointSaleInterface", mappedBy="user", orphanRemoval=true)
- */
- protected $userPointSales;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\User\UserMerchantInterface", mappedBy="user", orphanRemoval=true)
- */
- protected $userMerchants;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Ticket\TicketInterface", mappedBy="user")
- */
- protected $tickets;
-
- /**
- * @ORM\Column(type="array", nullable=true)
- */
- protected $ticketTypesNotification = [];
-
-
- /**
- * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface", mappedBy="users")
- */
- protected $reductionCredits;
-
-
- public function __construct()
- {
- $this->addresses = new ArrayCollection();
- $this->orders = new ArrayCollection();
- $this->groupUsers = new ArrayCollection();
- $this->newsletters = new ArrayCollection();
- $this->favoriteProductFamilies = new ArrayCollection();
- $this->userPointSales = new ArrayCollection();
- $this->userMerchants = new ArrayCollection();
- $this->reductionCredits = new ArrayCollection();
- $this->tickets = new ArrayCollection();
- }
-
- public function __toString()
- {
- return $this->getSummary();
- }
-
- public function getSummary()
- {
- return '#' . $this->getId() . ' ' . strtoupper($this->getLastname()) . ' ' . $this->getFirstname(
- ) . ' (' . $this->getEmail() . ')';
- }
-
- public function getName(): ?string
- {
- return (string)ucfirst(strtolower($this->getFirstname())) . ' ' . strtoupper($this->getLastname());
- }
-
- // isUserLinkedToPointSale
- public function isLinkedToPointSale(PointSaleInterface $pointSale)
- {
- foreach ($this->getUserPointSales() as $userPointSale) {
- if ($userPointSale->getPointSale()->getId() == $pointSale->getId()) {
- return true;
- }
- }
-
- return false;
- }
-
- public function getPhone(): ?string
- {
- return $this->phone;
- }
-
- public function setPhone(?string $phone): self
- {
- $this->phone = $phone;
-
- return $this;
- }
-
- public function getBehaviorDisplayPrice(): ?string
- {
- return $this->behaviorDisplayPrice;
- }
-
- public function setBehaviorDisplayPrice(?string $behaviorDisplayPrice): self
- {
- $this->behaviorDisplayPrice = $behaviorDisplayPrice;
-
- return $this;
- }
-
- public function getFavoriteMerchant(): ?MerchantInterface
- {
- return $this->favoriteMerchant;
- }
-
- public function setFavoriteMerchant(?MerchantInterface $merchant): self
- {
- $this->favoriteMerchant = $merchant;
-
- return $this;
- }
-
- /**
- * @return Collection|AddressInterface[]
- */
- public function getAddresses($status = null): Collection
- {
- if ($status) {
- $addressToReturn = new ArrayCollection();
- foreach ($this->addresses as $address) {
- if ($address->getStatus() == $status) {
- $addressToReturn[] = $address;
- }
- }
- return $addressToReturn;
- } else {
- return $this->addresses;
- }
- }
-
- public function addAddress(AddressInterface $address): self
- {
- if (!$this->addresses->contains($address)) {
- $this->addresses[] = $address;
- $address->setUser($this);
- }
-
- return $this;
- }
-
- public function removeAddress(AddressInterface $address): self
- {
- if ($this->addresses->contains($address)) {
- $this->addresses->removeElement($address);
- // set the owning side to null (unless already changed)
- if ($address->getUser() === $this) {
- $address->setUser(null);
- }
- }
-
- return $this;
- }
-
- /**
- * @return Collection|OrderShopInterface[]
- */
- public function getOrders(): Collection
- {
- return $this->orders;
- }
-
- public function addOrder(OrderShopInterface $order): self
- {
- if (!$this->orders->contains($order)) {
- $this->orders[] = $order;
- $order->setUser($this);
- }
-
- return $this;
- }
-
- public function removeOrder(OrderShopInterface $order): self
- {
- if ($this->orders->contains($order)) {
- $this->orders->removeElement($order);
- // set the owning side to null (unless already changed)
- if ($order->getUser() === $this) {
- $order->setUser(null);
- }
- }
-
- return $this;
- }
-
- public function getFirstname(): ?string
- {
- return $this->firstname;
- }
-
- public function setFirstname(?string $firstname): self
- {
- $this->firstname = $firstname;
-
- return $this;
- }
-
- public function getLastname(): ?string
- {
- return $this->lastname;
- }
-
- public function setLastname(?string $lastname): self
- {
- $this->lastname = $lastname;
-
- return $this;
- }
-
- public function getGender(): ?bool
- {
- return $this->gender;
- }
-
- public function setGender(?bool $gender): self
- {
- $this->gender = $gender;
-
- return $this;
- }
-
- /**
- * @return Collection|NewsletterInterface[]
- */
- public function getNewsletters(): Collection
- {
- return $this->newsletters;
- }
-
- public function addNewsletter(NewsletterInterface $newsletter): self
- {
- if (!$this->newsletters->contains($newsletter)) {
- $this->newsletters[] = $newsletter;
- }
-
- return $this;
- }
-
- public function removeNewsletter(NewsletterInterface $newsletter): self
- {
- if ($this->newsletters->contains($newsletter)) {
- $this->newsletters->removeElement($newsletter);
- }
-
- return $this;
- }
-
-
- /**
- * @return Collection|ProductFamilyInterface[]
- */
- public function getFavoriteProductFamilies(): Collection
- {
- return $this->favoriteProductFamilies;
- }
-
- public function addFavoriteProductFamily(ProductFamilyInterface $favoriteProductFamily): self
- {
- if (!$this->favoriteProductFamilies->contains($favoriteProductFamily)) {
- $this->favoriteProductFamilies[] = $favoriteProductFamily;
- }
-
- return $this;
- }
-
- public function removeFavoriteProductFamily(ProductFamilyInterface $favoriteProductFamily): self
- {
- if ($this->favoriteProductFamilies->contains($favoriteProductFamily)) {
- $this->favoriteProductFamilies->removeElement($favoriteProductFamily);
- }
-
- return $this;
- }
-
- /**
- * @return Collection|UserPointSaleInterface[]
- */
- public function getUserPointSales(): Collection
- {
- return $this->userPointSales;
- }
-
- public function addUserPointSale(UserPointSaleInterface $userPointSale): self
- {
- if (!$this->userPointSales->contains($userPointSale)) {
- $this->userPointSales[] = $userPointSale;
- $userPointSale->setUser($this);
- }
-
- return $this;
- }
-
- public function removeUserPointSale(UserPointSaleInterface $userPointSale): self
- {
- if ($this->userPointSales->contains($userPointSale)) {
- $this->userPointSales->removeElement($userPointSale);
- // set the owning side to null (unless already changed)
- if ($userPointSale->getUser() === $this) {
- $userPointSale->setUser(null);
- }
- }
-
- return $this;
- }
-
- /**
- * @return Collection|TicketInterface[]
- */
- public function getTickets(): Collection
- {
- return $this->tickets;
- }
-
- public function addTicket(TicketInterface $ticket): self
- {
- if (!$this->tickets->contains($ticket)) {
- $this->tickets[] = $ticket;
- $ticket->setUser($this);
- }
-
- return $this;
- }
-
- public function removeTicket(TicketInterface $ticket): self
- {
- if ($this->tickets->contains($ticket)) {
- $this->tickets->removeElement($ticket);
- // set the owning side to null (unless already changed)
- if ($ticket->getUser() === $this) {
- $ticket->setUser(null);
- }
- }
-
- return $this;
- }
-
- public function getCreatedAt(): ?\DateTimeInterface
- {
- return $this->createdAt;
- }
-
- public function setCreatedAt(\DateTimeInterface $createdAt): self
- {
- $this->createdAt = $createdAt;
-
- return $this;
- }
-
- public function getUpdatedAt(): ?\DateTimeInterface
- {
- return $this->updatedAt;
- }
-
- public function setUpdatedAt(\DateTimeInterface $updatedAt): self
- {
- $this->updatedAt = $updatedAt;
-
- return $this;
- }
-
-
- public function getTicketTypesNotification(): ?array
- {
- return $this->ticketTypesNotification;
- }
-
- public function setTicketTypesNotification(?array $ticketTypesNotification): self
- {
- $this->ticketTypesNotification = $ticketTypesNotification;
-
- return $this;
- }
-
- /**
- * @return Collection|ReductionCreditInterface[]
- */
- public function getReductionCredits(): Collection
- {
- return $this->reductionCredits;
- }
-
- public function addReductionCredit(ReductionCreditInterface $reductionCredit): self
- {
- if (!$this->reductionCredits->contains($reductionCredit)) {
- $this->reductionCredits[] = $reductionCredit;
- $reductionCredit->addUser($this);
- }
-
- return $this;
- }
-
- public function removeReductionCredit(ReductionCreditInterface $reductionCredit): self
- {
- if ($this->reductionCredits->contains($reductionCredit)) {
- $this->reductionCredits->removeElement($reductionCredit);
- $reductionCredit->removeUser($this);
- }
-
- return $this;
- }
-
- }
|