<?php
namespace App\Entity;
use App\Entity\Media;
use App\Repository\UserRepository;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Blameable\Traits\BlameableEntity;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\Table(name: '`user`')]
#[UniqueEntity('email', 'general.email_already_exists')]
#[UniqueEntity('username', 'general.email_already_exists')]
#[UniqueEntity('nickname', 'general.nickname_already_exists')]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
use BlameableEntity; //Hook blameable behavior. Updates createdBy, updatedBy fields
use TimestampableEntity; //Hook timestampable behavior. Updates createdAt, updatedAt fields
const ROLE_USER = "ROLE_USER";
const ROLE_INFLUENCER = 'ROLE_INFLUENCER';
const ROLE_ADMIN = 'ROLE_ADMIN';
const ROLE_SUPER_ADMIN = 'ROLE_SUPER_ADMIN';
const SEX_MAN = 0;
const SEX_WOMAN = 1;
const SEX_OTHER = 2;
const SEX_PREFER_NOT_SAY = 3;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: "IDENTITY")]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 180, unique: true)]
#[Assert\NotNull()]
#[Assert\Length(max: 180)]
private ?string $username = null;
#[ORM\Column(length: 180, unique: true)]
#[Assert\NotNull()]
#[Assert\Length(max: 180)]
private ?string $nickname = null;
#[ORM\Column]
private array $roles = ['ROLE_USER'];
/**
* @var string The hashed password
*/
#[ORM\Column]
private ?string $password = null;
#[ORM\Column(length: 255, unique: true)]
#[Assert\NotNull()]
#[Assert\Email]
#[Assert\Length(max: 255)]
private ?string $email = null;
#[ORM\Column]
private ?bool $isOnBoarding = true;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $acceptedCommunications = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $acceptedPolicies = null;
#[ORM\Column]
private ?bool $isActive = true;
#[ORM\Column]
private ?bool $legalAge = true;
#[ORM\Column]
private ?bool $isNotificationsActive = true;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Address::class, orphanRemoval: true)]
private Collection $addresses;
#[ORM\OneToOne(inversedBy: 'user', cascade: ['persist', 'remove'])]
private ?Media $avatar = null;
#[ORM\ManyToMany(targetEntity: Category::class, inversedBy: 'users')]
private Collection $categoryInterests;
#[ORM\ManyToMany(targetEntity: Subcategory::class, inversedBy: 'users')]
private Collection $subcategoryInterests;
#[ORM\Column(type: 'boolean', options: ['default' => false])]
private $isVerified = false;
#[ORM\Column(length: 100)]
//#[Assert\NotNull()]
#[Assert\Length(max: 100)]
private ?string $name = null;
#[ORM\Column(length: 255)]
//#[Assert\NotNull()]
#[Assert\Length(max: 255)]
private ?string $surname = null;
#[ORM\Column(length: 100, nullable: true)]
#[Assert\Length(max: 100)]
private ?string $cif = null;
#[ORM\Column(length: 100, nullable: true)]
#[Assert\Length(max: 100)]
private ?string $phone = null;
#[ORM\Column(length: 100, nullable: true)]
#[Assert\Length(max: 100)]
private ?string $cpostal = null;
#[ORM\Column]
//#[Assert\NotNull()]
private ?int $sex = 3;
#[ORM\OneToOne(mappedBy: 'buyer', cascade: ['persist', 'remove'])]
private ?ShoppingCart $shoppingCart = null;
#[ORM\OneToMany(mappedBy: 'buyer', targetEntity: Order::class)]
private Collection $orders;
#[ORM\OneToMany(mappedBy: 'owner', targetEntity: Card::class)]
private Collection $cards;
#[ORM\ManyToMany(targetEntity: Product::class, inversedBy: "userFavourites")]
private Collection $favouriteProducts;
#[ORM\ManyToMany(targetEntity: Product::class, mappedBy: "fakeTriweersInOffer")]
private Collection $asFakeTriweerInOffer;
#[ORM\OneToMany(mappedBy: 'owner', targetEntity: Wallet::class)]
private Collection $wallets;
#[ORM\Column(length: 500, nullable: true)]
private ?string $holdedId = null;
#[ORM\Column(nullable: true)]
private ?bool $notificationWhatsapp = null;
#[ORM\Column(nullable: true)]
private ?string $emailToken = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $emailTokenExpiresAt = null;
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
//#[Assert\NotNull()]
#[Assert\LessThan('today')]
private ?\DateTimeInterface $birthday = null;
#[ORM\OneToMany(mappedBy: 'Buyer', targetEntity: ProductReturn::class)]
private Collection $productReturns;
/**
* @var ArrayCollection
*/
#[ORM\OneToMany(mappedBy: 'mainUser', targetEntity: FriendTriweer::class)]
private Collection $friends;
/**
* @var ArrayCollection
*/
#[ORM\OneToMany(mappedBy: 'friendUser', targetEntity: FriendTriweer::class)]
private Collection $friendships;
#[ORM\OneToMany(mappedBy: 'userToShare', targetEntity: SharedAddress::class)]
private Collection $sharedAddressesToMe;
#[ORM\ManyToOne(inversedBy: 'shareFavouriteProductUsers')]
#[ORM\JoinColumn(nullable: false)]
private ?ShareType $shareFavouriteProductsType = null;
#[ORM\ManyToOne(inversedBy: 'shareShoppingUsers')]
#[ORM\JoinColumn(nullable: false)]
private ?ShareType $shareShoppingType = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: true, options: ['default' => 1])]
private ?Language $language = null;
#[ORM\OneToMany(mappedBy: 'mainUser', targetEntity: BuyingGroup::class)]
private Collection $buyingGroups;
#[ORM\ManyToMany(targetEntity: BuyingGroup::class, inversedBy: 'members')]
private Collection $memberBuyingGroups;
#[ORM\Column(type: 'boolean', options: ['default' => false])]
private ?bool $bankTransferActive = false;
#[ORM\ManyToOne(targetEntity: PaymentMethod::class, inversedBy: 'users')]
#[ORM\JoinColumn(nullable: false)]
private ?PaymentMethod $paymentMethod = null;
public function __construct()
{
$this->addresses = new ArrayCollection();
$this->categoryInterests = new ArrayCollection();
$this->subcategoryInterests = new ArrayCollection();
$this->acceptedPolicies = new DateTime();
$this->orders = new ArrayCollection();
$this->cards = new ArrayCollection();
$this->favouriteProducts = new ArrayCollection();
$this->asFakeTriweerInOffer = new ArrayCollection();
$this->wallets = new ArrayCollection();
$this->productReturns = new ArrayCollection();
$this->friends = new ArrayCollection();
$this->friendships = new ArrayCollection();
$this->sharedAddressesToMe = new ArrayCollection();
$this->buyingGroups = new ArrayCollection();
$this->memberBuyingGroups = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
public function getNickname(): ?string
{
return $this->nickname;
}
public function setNickname(string $nickname): self
{
$this->nickname = $nickname;
return $this;
}
public function getPaymentMethod(): ?PaymentMethod
{
return $this->paymentMethod;
}
public function setPaymentMethod(?PaymentMethod $paymentMethod): self
{
$this->paymentMethod = $paymentMethod;
return $this;
}
public function createNewDefaultNickname(): self
{
if ($this->getName() || $this->getSurname()) {
$this->nickname = mb_strtolower(
str_replace(
' ',
'.',
$this->getName() . '.' . $this->getSurname()
)
);
}
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->username;
}
public function setIsInfluencer(bool $isInfluencer): self
{
if ($isInfluencer) {
$this->addRoles([self::ROLE_INFLUENCER]);
} else {
$this->removeRoles([self::ROLE_INFLUENCER]);
}
return $this;
}
public function getIsInfluencer(): bool
{
return in_array(self::ROLE_INFLUENCER, $this->roles);
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
public function addRoles(array $rolesToAdd): self
{
$this->roles = array_unique(array_merge($this->roles, $rolesToAdd));
return $this;
}
public function removeRoles(array $rolesToRemove): self
{
$this->roles = array_diff($this->roles, $rolesToRemove);
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function isOnBoarding(): ?bool
{
return $this->isOnBoarding;
}
public function setIsOnBoarding(bool $isOnBoarding): self
{
$this->isOnBoarding = $isOnBoarding;
return $this;
}
public function getAcceptedCommunications(): ?\DateTimeInterface
{
return $this->acceptedCommunications;
}
public function setAcceptedCommunications(?\DateTimeInterface $acceptedCommunications): self
{
$this->acceptedCommunications = $acceptedCommunications;
return $this;
}
public function getAcceptedPolicies(): ?\DateTimeInterface
{
return $this->acceptedPolicies;
}
public function setAcceptedPolicies(?\DateTimeInterface $acceptedPolicies): self
{
$this->acceptedPolicies = $acceptedPolicies;
return $this;
}
public function isActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
public function legalAge(): ?bool
{
return $this->legalAge;
}
public function setLegalAge(bool $legalAge): self
{
$this->legalAge = $legalAge;
return $this;
}
public function isNotificationsActive(): ?bool
{
return $this->isNotificationsActive;
}
public function setIsNotificationsActive(bool $isNotificationsActive): self
{
$this->isNotificationsActive = $isNotificationsActive;
return $this;
}
/**
* @return Collection<int, Address>
*/
public function getShippingAddresses(): Collection
{
return $this->addresses->filter(function (Address $address) {
return !$address->isIsBillingAddress();
});
}
/**
* @return Collection<int, Address>
*/
public function getBillingAddresses(): Collection
{
return $this->addresses->filter(function (Address $address) {
return $address->isIsBillingAddress();
});
}
/**
* @return Collection<int, Address>
*/
public function getAddresses(): Collection
{
return $this->addresses;
}
public function addAddress(Address $address): self
{
if (!$this->addresses->contains($address)) {
$this->addresses->add($address);
$address->setUser($this);
}
return $this;
}
public function removeAddress(Address $address): self
{
if ($this->addresses->removeElement($address)) {
// set the owning side to null (unless already changed)
if ($address->getUser() === $this) {
$address->setUser(null);
}
}
return $this;
}
/**
* Find user's main address and return it. If the user has more than 1 main address return the first one found
*
* @return Address|null
*/
public function getMainAddress(): ?Address
{
foreach ($this->addresses as $address) {
if ($address->isIsDefaultAddress()) {
return $address;
}
}
return null;
}
public function getAvatar(): ?Media
{
return $this->avatar;
}
public function setAvatar(?Media $avatar): self
{
$avatar->setDirectory('user');
$this->avatar = $avatar;
return $this;
}
/**
* @return Collection<int, Category>
*/
public function getCategoryInterests(): Collection
{
return $this->categoryInterests;
}
public function addCategoryInterest(Category $categoryInterest): self
{
if (!$this->categoryInterests->contains($categoryInterest)) {
$this->categoryInterests->add($categoryInterest);
}
return $this;
}
public function removeCategoryInterest(Category $categoryInterest): self
{
$this->categoryInterests->removeElement($categoryInterest);
return $this;
}
/**
* @return Collection<int, Subcategory>
*/
public function getSubcategoryInterests(): Collection
{
return $this->subcategoryInterests;
}
public function addSubcategoryInterest(Subcategory $subcategoryInterest): self
{
if (!$this->subcategoryInterests->contains($subcategoryInterest)) {
$this->subcategoryInterests->add($subcategoryInterest);
}
return $this;
}
public function removeSubcategoryInterest(Subcategory $subcategoryInterest): self
{
$this->subcategoryInterests->removeElement($subcategoryInterest);
return $this;
}
public function isVerified(): bool
{
return $this->isVerified;
}
public function setIsVerified(bool $isVerified): self
{
$this->isVerified = $isVerified;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getSurname(): ?string
{
return $this->surname;
}
public function setSurname(?string $surname): self
{
$this->surname = $surname;
return $this;
}
public function getFullName(): ?string
{
return $this->getName() . ' ' . $this->getSurname();
}
public function getFullNameWithId(): ?string
{
return $this->getName() . ' ' . $this->getSurname() . " (ID: " . $this->getId() . ")";
}
public function getCif(): ?string
{
return $this->cif;
}
public function setCif(?string $cif): self
{
$this->cif = $cif;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = str_replace(' ', '', $phone);
return $this;
}
public function getCpostal(): ?string
{
return $this->cpostal;
}
public function setCpostal(?string $cpostal): self
{
$this->cpostal = $cpostal;
return $this;
}
public function getSex(): ?string
{
return $this->sex;
}
public function setSex(?int $sex): self
{
$this->sex = $sex;
return $this;
}
public function getShoppingCartItemNumber(): ?int
{
if ($this->shoppingCart && $this->shoppingCart->getShoppingCartDetails()) {
return $this->shoppingCart->getShoppingCartDetails()->count();
}
return null;
}
public function getShoppingCart(): ?ShoppingCart
{
return $this->shoppingCart;
}
public function setShoppingCart(ShoppingCart $shoppingCart): self
{
// set the owning side of the relation if necessary
if ($shoppingCart->getBuyer() !== $this) {
$shoppingCart->setBuyer($this);
}
$this->shoppingCart = $shoppingCart;
return $this;
}
public function emptyShoppingCart(): self
{
$this->shoppingCart = null;
return $this;
}
/**
* @return Collection<int, Order>
*/
public function getOrders(): Collection
{
return $this->orders;
}
public function addOrder(Order $order): self
{
if (!$this->orders->contains($order)) {
$this->orders->add($order);
$order->setBuyer($this);
}
return $this;
}
public function removeOrder(Order $order): self
{
if ($this->orders->removeElement($order)) {
// set the owning side to null (unless already changed)
if ($order->getBuyer() === $this) {
$order->setBuyer(null);
}
}
return $this;
}
/**
* Find user's last order by updatedAt datetime field
*
* @return Order|null
*/
public function getLastOrder(): ?Order
{
$lastOrder = null;
foreach ($this->orders as $order) {
if ($lastOrder == null) {
$lastOrder = $order;
}
if ($lastOrder->getUpdatedAt() < $order->getUpdatedAt()) {
$lastOrder = $order;
}
}
return $lastOrder;
}
/**
* @return Collection<int, Card>
*/
public function getCards(): Collection
{
return $this->cards;
}
public function addCard(Card $card): self
{
if (!$this->cards->contains($card)) {
$this->cards->add($card);
$card->setOwner($this);
}
return $this;
}
public function removeCard(Card $card): self
{
if ($this->cards->removeElement($card)) {
// set the owning side to null (unless already changed)
if ($card->getOwner() === $this) {
$card->setOwner(null);
}
}
return $this;
}
/**
* @return Collection<int, Product>
*/
public function getFavouriteProducts(): Collection
{
return $this->favouriteProducts;
}
public function addFavouriteProduct(Product $favouriteProduct): self
{
if (!$this->favouriteProducts->contains($favouriteProduct)) {
$this->favouriteProducts->add($favouriteProduct);
}
return $this;
}
public function removeFavouriteProduct(Product $favouriteProduct): self
{
$this->favouriteProducts->removeElement($favouriteProduct);
return $this;
}
/**
* @return Collection<int, Product>
*/
public function getAsFakeTriweerInOffer(): Collection
{
return $this->asFakeTriweerInOffer;
}
/**
* @return float
*/
public function getPositiveAvailableWalletCoins(): float
{
$availableCoins = $this->getAvailableWalletCoins();
if ($availableCoins < 0) {
$availableCoins = 0;
}
return $availableCoins;
}
/**
* @return float
*/
public function getAvailableWalletCoins(): float
{
$sum = 0;
foreach ($this->getWallets() as $wallet) {
if (
($wallet->getSpentOrder() &&
$wallet->getSpentOrder()->getStatus()->getKey() == OrderStatus::PENDING_PAYMENT
) ||
($wallet->getOrderDetail() &&
$wallet->getOrderDetail()->getHeader()->getStatus()->getKey() == OrderStatus::PENDING_PAYMENT
)
) {
continue;
}
if (
!$wallet->isCancelled() && !$wallet->isPending()
) {
$sum += $wallet->getAmount();
}
}
return $sum;
}
/**
* @return Collection<int, Wallet>
*/
public function getPendingWalletCoins(): float
{
$sum = 0;
foreach ($this->getWallets() as $wallet) {
if (
($wallet->getSpentOrder() &&
$wallet->getSpentOrder()->getStatus()->getKey() == OrderStatus::PENDING_PAYMENT
) ||
($wallet->getOrderDetail() &&
$wallet->getOrderDetail()->getHeader()->getStatus()->getKey() == OrderStatus::PENDING_PAYMENT
)
) {
continue;
}
if (
!$wallet->isCancelled() && $wallet->isPending()
) {
$sum += $wallet->getAmount();
}
}
return $sum;
}
/**
* @return Collection<int, Wallet>
*/
public function getWallets(): Collection
{
return $this->wallets;
}
public function addWallet(Wallet $wallet): self
{
if (!$this->wallets->contains($wallet)) {
$this->wallets->add($wallet);
$wallet->setOwner($this);
}
return $this;
}
public function removeWallet(Wallet $wallet): self
{
if ($this->wallets->removeElement($wallet)) {
// set the owning side to null (unless already changed)
if ($wallet->getOwner() === $this) {
$wallet->setOwner(null);
}
}
return $this;
}
public function getHoldedId(): ?string
{
return $this->holdedId;
}
public function setHoldedId(?string $holdedId): self
{
$this->holdedId = $holdedId;
return $this;
}
public function isNotificationWhatsapp(): ?bool
{
return $this->notificationWhatsapp;
}
public function setNotificationWhatsapp(?bool $notificationWhatsapp): self
{
$this->notificationWhatsapp = $notificationWhatsapp;
return $this;
}
public function getEmailToken(): ?string
{
return $this->emailToken;
}
public function setEmailToken(string $emailToken): self
{
$this->emailToken = $emailToken;
return $this;
}
public function getEmailTokenExpiresAt(): ?\DateTimeInterface
{
return $this->emailTokenExpiresAt;
}
public function setEmailTokenExpiresAt(?\DateTimeInterface $emailTokenExpiresAt): self
{
$this->emailTokenExpiresAt = $emailTokenExpiresAt;
return $this;
}
public function getIsAdult(): ?bool
{
if (!$this->birthday) {
return false;
}
$today = new \DateTime(date("Y-m-d"));
$interval = $today->diff($this->birthday);
if (intval($interval->y) > 18) {
return true;
} else {
return false;
}
}
public function getBirthday(): ?\DateTimeInterface
{
return $this->birthday;
}
public function setBirthday(?\DateTimeInterface $birthday): self
{
$this->birthday = $birthday;
return $this;
}
/**
* @return Collection<int, ProductReturn>
*/
public function getProductReturns(): Collection
{
return $this->productReturns;
}
public function addProductReturn(ProductReturn $productReturn): self
{
if (!$this->productReturns->contains($productReturn)) {
$this->productReturns->add($productReturn);
$productReturn->setBuyer($this);
}
return $this;
}
public function removeProductReturn(ProductReturn $productReturn): self
{
if ($this->productReturns->removeElement($productReturn)) {
// set the owning side to null (unless already changed)
if ($productReturn->getBuyer() === $this) {
$productReturn->setBuyer(null);
}
}
return $this;
}
/**
* @return Collection<int, FriendTriweer>
*/
public function getFriends(): Collection
{
return $this->friends;
}
/**
* @return Collection<int, FriendTriweer>
*/
public function getFriendships(): Collection
{
return $this->friendships;
}
/**
* @param User $friendUser
* @return FriendTriweer|false
*/
public function getFriendTriweer(User $friendUser)
{
$criteria = Criteria::create()
->andWhere(Criteria::expr()->eq('mainUser', $this))
->andWhere(Criteria::expr()->eq('friendUser', $friendUser));
return $this->friends->matching($criteria)->first();
}
public function addFriend(FriendTriweer $friend): self
{
if (!$this->friends->contains($friend)) {
$this->friends->add($friend);
$friend->setMainUser($this);
}
return $this;
}
public function removeFriend(FriendTriweer $friend): self
{
if ($this->friends->removeElement($friend)) {
// set the owning side to null (unless already changed)
if ($friend->getMainUser() === $this) {
$friend->setMainUser(null);
}
}
return $this;
}
/**
* @return Collection<int, SharedAddress>
*/
public function getSharedAddressesToMe(): Collection
{
return $this->sharedAddressesToMe;
}
public function addSharedAddressesToMe(SharedAddress $sharedAddressesToMe): self
{
if (!$this->sharedAddressesToMe->contains($sharedAddressesToMe)) {
$this->sharedAddressesToMe->add($sharedAddressesToMe);
$sharedAddressesToMe->setUserToShare($this);
}
return $this;
}
public function removeSharedAddressesToMe(SharedAddress $sharedAddressesToMe): self
{
if ($this->sharedAddressesToMe->removeElement($sharedAddressesToMe)) {
// set the owning side to null (unless already changed)
if ($sharedAddressesToMe->getUserToShare() === $this) {
$sharedAddressesToMe->setUserToShare(null);
}
}
return $this;
}
public function getLanguage(): ?Language
{
return $this->language;
}
public function setLanguage(?Language $language): self
{
$this->language = $language;
return $this;
}
public function getShareFavouriteProductsType(): ?ShareType
{
return $this->shareFavouriteProductsType;
}
public function setShareFavouriteProductsType(?ShareType $shareFavouriteProductsType): self
{
$this->shareFavouriteProductsType = $shareFavouriteProductsType;
return $this;
}
public function getShareShoppingType(): ?ShareType
{
return $this->shareShoppingType;
}
public function setShareShoppingType(?ShareType $shareShoppingType): self
{
$this->shareShoppingType = $shareShoppingType;
return $this;
}
/**
* @return Collection<int, BuyingGroup>
*/
public function getBuyingGroups(): Collection
{
return $this->buyingGroups;
}
public function addBuyingGroup(BuyingGroup $buyingGroup): self
{
if (!$this->buyingGroups->contains($buyingGroup)) {
$this->buyingGroups->add($buyingGroup);
$buyingGroup->setMainUser($this);
}
return $this;
}
public function removeBuyingGroup(BuyingGroup $buyingGroup): self
{
if ($this->buyingGroups->removeElement($buyingGroup)) {
// set the owning side to null (unless already changed)
if ($buyingGroup->getMainUser() === $this) {
$buyingGroup->setMainUser(null);
}
}
return $this;
}
/**
* @return Collection<int, BuyingGroup>
*/
public function getMemberBuyingGroups(): Collection
{
return $this->memberBuyingGroups;
}
public function addMemberBuyingGroup(BuyingGroup $buyingGroup): self
{
if (!$this->memberBuyingGroups->contains($buyingGroup)) {
$this->memberBuyingGroups->add($buyingGroup);
$buyingGroup->setMainUser($this);
}
return $this;
}
public function removeMemberBuyingGroup(BuyingGroup $buyingGroup): self
{
if ($this->memberBuyingGroups->removeElement($buyingGroup)) {
// set the owning side to null (unless already changed)
if ($buyingGroup->getMainUser() === $this) {
$buyingGroup->setMainUser(null);
}
}
return $this;
}
public function isBankTransferActive(): ?bool
{
return $this->bankTransferActive;
}
public function setBankTransferActive(bool $bankTransferActive): self
{
$this->bankTransferActive = $bankTransferActive;
return $this;
}
}