You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use App\Entity\Newsletter;
  4. use App\Entity\UserPointSale;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use FOS\UserBundle\Model\User as UserModelFOS;
  9. use Lc\ShopBundle\Context\MerchantInterface;
  10. /**
  11. * @ORM\MappedSuperclass()
  12. *
  13. */
  14. abstract class User extends UserModelFOS
  15. {
  16. /**
  17. * @ORM\Column(type="string", length=20, nullable=true)
  18. */
  19. protected $phone;
  20. /**
  21. * @ORM\Column(type="string", length=64, nullable=true)
  22. */
  23. protected $behaviorDisplayPrice;
  24. /**
  25. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface")
  26. */
  27. protected $merchant;
  28. /**
  29. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\CreditHistoryInterface", mappedBy="user", orphanRemoval=true)
  30. */
  31. protected $creditHistories;
  32. /**
  33. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\AddressInterface", mappedBy="user", cascade={"persist"})
  34. */
  35. protected $addresses;
  36. /**
  37. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="user")
  38. */
  39. protected $orders;
  40. /**
  41. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\CartInterface", mappedBy="user")
  42. */
  43. protected $carts;
  44. /**
  45. * @ORM\Column(type="string", length=64, nullable=true)
  46. */
  47. protected $firstname;
  48. /**
  49. * @ORM\Column(type="string", length=64, nullable=true)
  50. */
  51. protected $lastname;
  52. /**
  53. * @ORM\Column(type="boolean", nullable=true)
  54. */
  55. protected $gender;
  56. /**
  57. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\NewsletterInterface", inversedBy="users")
  58. */
  59. protected $newsletters;
  60. /**
  61. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\GroupUserInterface", inversedBy="users")
  62. */
  63. protected $groupUsers;
  64. /**
  65. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductFamilyInterface")
  66. */
  67. protected $favoriteProductFamilies;
  68. /**
  69. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\UserPointSaleInterface", mappedBy="user", orphanRemoval=true)
  70. */
  71. protected $userPointSales;
  72. public function __construct()
  73. {
  74. parent::__construct();
  75. $this->creditHistories = new ArrayCollection();
  76. $this->addresses = new ArrayCollection();
  77. $this->orders = new ArrayCollection();
  78. $this->carts = new ArrayCollection();
  79. $this->groupUsers = new ArrayCollection();
  80. $this->newsletters = new ArrayCollection();
  81. $this->favoriteProductFamilies = new ArrayCollection();
  82. $this->userPointSales = new ArrayCollection();
  83. }
  84. public function getSummary()
  85. {
  86. return strtoupper($this->getLastname()).' '.$this->getFirstname(). ' ('.$this->getEmail().')';
  87. }
  88. public function setEmail($email)
  89. {
  90. $this->setUsername($email);
  91. return parent::setEmail($email);
  92. }
  93. public function getPhone(): ?string
  94. {
  95. return $this->phone;
  96. }
  97. public function setPhone(?string $phone): self
  98. {
  99. $this->phone = $phone;
  100. return $this;
  101. }
  102. public function getBehaviorDisplayPrice(): ?string
  103. {
  104. return $this->behaviorDisplayPrice;
  105. }
  106. public function setBehaviorDisplayPrice(?string $behaviorDisplayPrice): self
  107. {
  108. $this->behaviorDisplayPrice = $behaviorDisplayPrice;
  109. return $this;
  110. }
  111. public function getMerchant(): ?MerchantInterface
  112. {
  113. return $this->merchant;
  114. }
  115. public function setMerchant(?MerchantInterface $merchant): self
  116. {
  117. $this->merchant = $merchant;
  118. return $this;
  119. }
  120. /**
  121. * @return Collection|CreditHistory[]
  122. */
  123. public function getCreditHistories(): Collection
  124. {
  125. return $this->creditHistories;
  126. }
  127. public function addCreditHistory(CreditHistory $creditHistory): self
  128. {
  129. if (!$this->creditHistories->contains($creditHistory)) {
  130. $this->creditHistories[] = $creditHistory;
  131. $creditHistory->setUser($this);
  132. }
  133. return $this;
  134. }
  135. public function removeCreditHistory(CreditHistory $creditHistory): self
  136. {
  137. if ($this->creditHistories->contains($creditHistory)) {
  138. $this->creditHistories->removeElement($creditHistory);
  139. // set the owning side to null (unless already changed)
  140. if ($creditHistory->getUser() === $this) {
  141. $creditHistory->setUser(null);
  142. }
  143. }
  144. return $this;
  145. }
  146. /**
  147. * @return Collection|Address[]
  148. */
  149. public function getAddresses(): Collection
  150. {
  151. return $this->addresses;
  152. }
  153. public function addAddress(Address $address): self
  154. {
  155. if (!$this->addresses->contains($address)) {
  156. $this->addresses[] = $address;
  157. $address->setUser($this);
  158. }
  159. return $this;
  160. }
  161. public function removeAddress(Address $address): self
  162. {
  163. if ($this->addresses->contains($address)) {
  164. $this->addresses->removeElement($address);
  165. // set the owning side to null (unless already changed)
  166. if ($address->getUser() === $this) {
  167. $address->setUser(null);
  168. }
  169. }
  170. return $this;
  171. }
  172. /**
  173. * @return Collection|ShopOrder[]
  174. */
  175. public function getOrders(): Collection
  176. {
  177. return $this->orders;
  178. }
  179. public function addOrder(OrderShop $order): self
  180. {
  181. if (!$this->orders->contains($order)) {
  182. $this->orders[] = $order;
  183. $order->setUser($this);
  184. }
  185. return $this;
  186. }
  187. public function removeOrder(OrderShop $order): self
  188. {
  189. if ($this->orders->contains($order)) {
  190. $this->orders->removeElement($order);
  191. // set the owning side to null (unless already changed)
  192. if ($order->getUser() === $this) {
  193. $order->setUser(null);
  194. }
  195. }
  196. return $this;
  197. }
  198. /**
  199. * @return Collection|Cart[]
  200. */
  201. public function getCarts(): Collection
  202. {
  203. return $this->carts;
  204. }
  205. public function addCart(Cart $cart): self
  206. {
  207. if (!$this->carts->contains($cart)) {
  208. $this->carts[] = $cart;
  209. $cart->setUser($this);
  210. }
  211. return $this;
  212. }
  213. public function removeCart(Cart $cart): self
  214. {
  215. if ($this->carts->contains($cart)) {
  216. $this->carts->removeElement($cart);
  217. // set the owning side to null (unless already changed)
  218. if ($cart->getUser() === $this) {
  219. $cart->setUser(null);
  220. }
  221. }
  222. return $this;
  223. }
  224. public function getFirstname(): ?string
  225. {
  226. return $this->firstname;
  227. }
  228. public function setFirstname(?string $firstname): self
  229. {
  230. $this->firstname = $firstname;
  231. return $this;
  232. }
  233. public function getLastname(): ?string
  234. {
  235. return $this->lastname;
  236. }
  237. public function setLastname(?string $lastname): self
  238. {
  239. $this->lastname = $lastname;
  240. return $this;
  241. }
  242. public function getGender(): ?bool
  243. {
  244. return $this->gender;
  245. }
  246. public function setGender(?bool $gender): self
  247. {
  248. $this->gender = $gender;
  249. return $this;
  250. }
  251. /**
  252. * @return Collection|Newsletter[]
  253. */
  254. public function getNewsletters(): Collection
  255. {
  256. return $this->newsletters;
  257. }
  258. public function addNewsletter(Newsletter $newsletter): self
  259. {
  260. if (!$this->newsletters->contains($newsletter)) {
  261. $this->newsletters[] = $newsletter;
  262. }
  263. return $this;
  264. }
  265. public function removeNewsletter(Newsletter $newsletter): self
  266. {
  267. if ($this->newsletters->contains($newsletter)) {
  268. $this->newsletters->removeElement($newsletter);
  269. }
  270. return $this;
  271. }
  272. /**
  273. * @return Collection|GroupUser[]
  274. */
  275. public function getGroupUsers(): Collection
  276. {
  277. return $this->groupUsers;
  278. }
  279. public function addGroupUser(GroupUser $groupUser): self
  280. {
  281. if (!$this->groupUsers->contains($groupUser)) {
  282. $this->groupUsers[] = $groupUser;
  283. $groupUser->addUser($this);
  284. }
  285. return $this;
  286. }
  287. public function removeGroupUser(GroupUser $groupUser): self
  288. {
  289. if ($this->groupUsers->contains($groupUser)) {
  290. $this->groupUsers->removeElement($groupUser);
  291. $groupUser->removeUser($this);
  292. }
  293. return $this;
  294. }
  295. /**
  296. * @return Collection|ProductFamily[]
  297. */
  298. public function getFavoriteProductFamilies(): Collection
  299. {
  300. return $this->favoriteProductFamilies;
  301. }
  302. public function addFavoriteProductFamily(ProductFamily $favoriteProductFamily): self
  303. {
  304. if (!$this->favoriteProductFamilies->contains($favoriteProductFamily)) {
  305. $this->favoriteProductFamilies[] = $favoriteProductFamily;
  306. }
  307. return $this;
  308. }
  309. public function removeFavoriteProductFamily(ProductFamily $favoriteProductFamily): self
  310. {
  311. if ($this->favoriteProductFamilies->contains($favoriteProductFamily)) {
  312. $this->favoriteProductFamilies->removeElement($favoriteProductFamily);
  313. }
  314. return $this;
  315. }
  316. /**
  317. * @return Collection|UserPointSale[]
  318. */
  319. public function getUserPointSales(): Collection
  320. {
  321. return $this->userPointSales;
  322. }
  323. public function addUserPointSale(UserPointSale $userPointSale): self
  324. {
  325. if (!$this->userPointSales->contains($userPointSale)) {
  326. $this->userPointSales[] = $userPointSale;
  327. $userPointSale->setUser($this);
  328. }
  329. return $this;
  330. }
  331. public function removeUserPointSale(UserPointSale $userPointSale): self
  332. {
  333. if ($this->userPointSales->contains($userPointSale)) {
  334. $this->userPointSales->removeElement($userPointSale);
  335. // set the owning side to null (unless already changed)
  336. if ($userPointSale->getUser() === $this) {
  337. $userPointSale->setUser(null);
  338. }
  339. }
  340. return $this;
  341. }
  342. }