Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

UserModel.php 8.7KB

3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <?php
  2. namespace Lc\CaracoleBundle\Model\User;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Lc\CaracoleBundle\Model\Address\AddressInterface;
  7. use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
  8. use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
  9. use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
  10. use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
  11. use Lc\SovBundle\Model\User\UserModel as SovUserModel;
  12. use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
  13. /**
  14. * @ORM\MappedSuperclass()
  15. *
  16. */
  17. abstract class UserModel extends SovUserModel
  18. {
  19. /**
  20. * @ORM\Column(type="string", length=64, nullable=true)
  21. */
  22. protected $behaviorDisplayPrice;
  23. /**
  24. * @ORM\Column(type="boolean", nullable=true)
  25. */
  26. protected $isSaleAlwaysOpen;
  27. /**
  28. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface")
  29. */
  30. protected $favoriteMerchant;
  31. /**
  32. * @ORM\Column(type="datetime", nullable=true)
  33. */
  34. protected $lastLogin;
  35. /**
  36. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Address\AddressInterface", mappedBy="user", cascade={"persist"})
  37. */
  38. protected $addresses;
  39. /**
  40. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Order\OrderShopInterface", mappedBy="user")
  41. */
  42. protected $orderShops;
  43. /**
  44. * @ORM\ManyToMany(targetEntity="Lc\SovBundle\Model\Newsletter\NewsletterInterface", inversedBy="users")
  45. */
  46. protected $newsletters;
  47. /**
  48. * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilyInterface")
  49. */
  50. protected $favoriteProductFamilies;
  51. /**
  52. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\User\UserPointSaleInterface", mappedBy="user", orphanRemoval=true)
  53. */
  54. protected $userPointSales;
  55. /**
  56. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\User\UserMerchantInterface", mappedBy="user", orphanRemoval=true)
  57. */
  58. protected $userMerchants;
  59. /**
  60. * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface", mappedBy="users")
  61. */
  62. protected $reductionCredits;
  63. public function __construct()
  64. {
  65. parent::__construct();
  66. $this->addresses = new ArrayCollection();
  67. $this->orderShops = new ArrayCollection();
  68. $this->groupUsers = new ArrayCollection();
  69. $this->newsletters = new ArrayCollection();
  70. $this->favoriteProductFamilies = new ArrayCollection();
  71. $this->userPointSales = new ArrayCollection();
  72. $this->userMerchants = new ArrayCollection();
  73. $this->reductionCredits = new ArrayCollection();
  74. }
  75. public function getBehaviorDisplayPrice(): ?string
  76. {
  77. return $this->behaviorDisplayPrice;
  78. }
  79. public function setBehaviorDisplayPrice(?string $behaviorDisplayPrice): self
  80. {
  81. $this->behaviorDisplayPrice = $behaviorDisplayPrice;
  82. return $this;
  83. }
  84. public function getIsSaleAlwaysOpen(): ?bool
  85. {
  86. return $this->isSaleAlwaysOpen;
  87. }
  88. public function setIsSaleAlwaysOpen(?bool $isSaleAlwaysOpen): self
  89. {
  90. $this->isSaleAlwaysOpen = $isSaleAlwaysOpen;
  91. return $this;
  92. }
  93. public function getFavoriteMerchant(): ?MerchantInterface
  94. {
  95. return $this->favoriteMerchant;
  96. }
  97. public function setFavoriteMerchant(?MerchantInterface $merchant): self
  98. {
  99. $this->favoriteMerchant = $merchant;
  100. return $this;
  101. }
  102. public function getLastLogin()
  103. {
  104. return $this->lastLogin;
  105. }
  106. public function setLastLogin(\DateTime $time = null)
  107. {
  108. $this->lastLogin = $time;
  109. return $this;
  110. }
  111. /**
  112. * @return Collection|AddressInterface[]
  113. */
  114. public function getAddresses($status = null): Collection
  115. {
  116. if ($status) {
  117. $addressToReturn = new ArrayCollection();
  118. foreach ($this->addresses as $address) {
  119. if ($address->getStatus() == $status) {
  120. $addressToReturn[] = $address;
  121. }
  122. }
  123. return $addressToReturn;
  124. } else {
  125. return $this->addresses;
  126. }
  127. }
  128. public function addAddress(AddressInterface $address): self
  129. {
  130. if (!$this->addresses->contains($address)) {
  131. $this->addresses[] = $address;
  132. $address->setUser($this);
  133. }
  134. return $this;
  135. }
  136. public function removeAddress(AddressInterface $address): self
  137. {
  138. if ($this->addresses->contains($address)) {
  139. $this->addresses->removeElement($address);
  140. // set the owning side to null (unless already changed)
  141. if ($address->getUser() === $this) {
  142. $address->setUser(null);
  143. }
  144. }
  145. return $this;
  146. }
  147. /**
  148. * @return Collection|OrderShopInterface[]
  149. */
  150. public function getOrderShops(): Collection
  151. {
  152. return $this->orderShops;
  153. }
  154. public function addOrderShop(OrderShopInterface $orderShop): self
  155. {
  156. if (!$this->orderShops->contains($orderShop)) {
  157. $this->orderShops[] = $orderShop;
  158. $orderShop->setUser($this);
  159. }
  160. return $this;
  161. }
  162. public function removeOrderShop(OrderShopInterface $orderShop): self
  163. {
  164. if ($this->orderShops->contains($orderShop)) {
  165. $this->orderShops->removeElement($orderShop);
  166. // set the owning side to null (unless already changed)
  167. if ($orderShop->getUser() === $this) {
  168. $orderShop->setUser(null);
  169. }
  170. }
  171. return $this;
  172. }
  173. /**
  174. * @return Collection|NewsletterInterface[]
  175. */
  176. public function getNewsletters(): Collection
  177. {
  178. return $this->newsletters;
  179. }
  180. public function addNewsletter(NewsletterInterface $newsletter): self
  181. {
  182. if (!$this->newsletters->contains($newsletter)) {
  183. $this->newsletters[] = $newsletter;
  184. }
  185. return $this;
  186. }
  187. public function removeNewsletter(NewsletterInterface $newsletter): self
  188. {
  189. if ($this->newsletters->contains($newsletter)) {
  190. $this->newsletters->removeElement($newsletter);
  191. }
  192. return $this;
  193. }
  194. /**
  195. * @return Collection|ProductFamilyInterface[]
  196. */
  197. public function getFavoriteProductFamilies(): Collection
  198. {
  199. return $this->favoriteProductFamilies;
  200. }
  201. public function addFavoriteProductFamily(ProductFamilyInterface $favoriteProductFamily): self
  202. {
  203. if (!$this->favoriteProductFamilies->contains($favoriteProductFamily)) {
  204. $this->favoriteProductFamilies[] = $favoriteProductFamily;
  205. }
  206. return $this;
  207. }
  208. public function removeFavoriteProductFamily(ProductFamilyInterface $favoriteProductFamily): self
  209. {
  210. if ($this->favoriteProductFamilies->contains($favoriteProductFamily)) {
  211. $this->favoriteProductFamilies->removeElement($favoriteProductFamily);
  212. }
  213. return $this;
  214. }
  215. /**
  216. * @return Collection|UserPointSaleInterface[]
  217. */
  218. public function getUserPointSales(): Collection
  219. {
  220. return $this->userPointSales;
  221. }
  222. public function addUserPointSale(UserPointSaleInterface $userPointSale): self
  223. {
  224. if (!$this->userPointSales->contains($userPointSale)) {
  225. $this->userPointSales[] = $userPointSale;
  226. $userPointSale->setUser($this);
  227. }
  228. return $this;
  229. }
  230. public function removeUserPointSale(UserPointSaleInterface $userPointSale): self
  231. {
  232. if ($this->userPointSales->contains($userPointSale)) {
  233. $this->userPointSales->removeElement($userPointSale);
  234. // set the owning side to null (unless already changed)
  235. if ($userPointSale->getUser() === $this) {
  236. $userPointSale->setUser(null);
  237. }
  238. }
  239. return $this;
  240. }
  241. /**
  242. * @return Collection|ReductionCreditInterface[]
  243. */
  244. public function getReductionCredits(): Collection
  245. {
  246. return $this->reductionCredits;
  247. }
  248. public function addReductionCredit(ReductionCreditInterface $reductionCredit): self
  249. {
  250. if (!$this->reductionCredits->contains($reductionCredit)) {
  251. $this->reductionCredits[] = $reductionCredit;
  252. $reductionCredit->addUser($this);
  253. }
  254. return $this;
  255. }
  256. public function removeReductionCredit(ReductionCreditInterface $reductionCredit): self
  257. {
  258. if ($this->reductionCredits->contains($reductionCredit)) {
  259. $this->reductionCredits->removeElement($reductionCredit);
  260. $reductionCredit->removeUser($this);
  261. }
  262. return $this;
  263. }
  264. }