<?php

namespace Lc\ShopBundle\Model;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

trait ReductionPropertyTrait
{

        /**
         * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\UserInterface")
         */
        protected $users;

        /**
         * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\GroupUserInterface")
         */
        protected $groupUsers;

        /**
         * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="productFamilies")
         * @ORM\JoinColumn(nullable=false)
         */
        protected $merchant;

        /**
         * @ORM\Column(type="datetime", nullable=true)
         */
        protected $dateStart;

        /**
         * @ORM\Column(type="datetime", nullable=true)
         */
        protected $dateEnd;

        /**
         * @ORM\Column(type="boolean")
         */
        protected $permanent;



        public function __construct()
        {
                $this->users = new ArrayCollection();
                $this->groupUsers = new ArrayCollection();
        }

        public function getMerchant(): ?Merchant
        {
                return $this->merchant;
        }

        public function setMerchant(?Merchant $merchant): self
        {
                $this->merchant = $merchant;

                return $this;
        }

        /**
         * @return Collection|User[]
         */
        public function getUsers(): Collection
        {
                return $this->users;
        }

        public function addUser(User $user): self
        {
                if (!$this->users->contains($user)) {
                        $this->users[] = $user;
                }

                return $this;
        }

        public function removeUser(User $user): self
        {
                if ($this->users->contains($user)) {
                        $this->users->removeElement($user);
                }

                return $this;
        }


        /**
         * @return Collection|GroupUser[]
         */
        public function getGroupUsers(): Collection
        {
                return $this->groupUsers;
        }

        public function addGroupUser(GroupUser $groupUser): self
        {
                if (!$this->groupUsers->contains($groupUser)) {
                        $this->groupUsers[] = $groupUser;
                }

                return $this;
        }

        public function removeGroupUser(GroupUser $groupUser): self
        {
                if ($this->groupUsers->contains($groupUser)) {
                        $this->groupUsers->removeElement($groupUser);
                }

                return $this;
        }


        public function getDateStart(): ?\DateTimeInterface
        {
                return $this->dateStart;
        }

        public function setDateStart(?\DateTimeInterface $dateStart): self
        {
                $this->dateStart = $dateStart;

                return $this;
        }

        public function getDateEnd(): ?\DateTimeInterface
        {
                return $this->dateEnd;
        }

        public function setDateEnd(?\DateTimeInterface $dateEnd): self
        {
                $this->dateEnd = $dateEnd;

                return $this;
        }

        public function getPermanent(): ?bool
        {
                return $this->permanent;
        }

        public function setPermanent(bool $permanent): self
        {
                $this->permanent = $permanent;

                return $this;
        }

}