src/Entity/Shop.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Exception;
  6. use function array_values;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Doctrine\ORM\Id as Id;
  9. use Doctrine\ORM\PersistentCollection;
  10. use function implode;
  11. use function is_null;
  12. /**
  13.  * Shops
  14.  *
  15.  * @ORM\Table(name="shops", indexes={@ORM\Index(name="fk_shops_cities_idx", columns={"city"}), @ORM\Index(name="fk_shops_shoptypes1_idx", columns={"type"}), @ORM\Index(name="fk_shops_shoppingareas1_idx", columns={"shopping_area"}), @ORM\Index(name="fk_shops_shoppingmalls1_idx", columns={"shopping_mall"})})
  16.  * @ORM\Entity(repositoryClass="App\Repository\ShopRepository")
  17.  */
  18. class Shop
  19. {
  20.     /**
  21.      * @var int
  22.      *
  23.      * @ORM\Column(name="shop_id", type="integer", nullable=false)
  24.      * @ORM\Id
  25.      * @ORM\GeneratedValue(strategy="IDENTITY")
  26.      */
  27.     private $id;
  28.     /**
  29.      * @var string
  30.      * @ORM\Column(name="_id", type="string", nullable=true)
  31.      */
  32.     protected $_id;
  33.     /**
  34.      * @var string
  35.      *
  36.      * @ORM\Column(name="name", type="string", length=255, nullable=false)
  37.      */
  38.     private $name;
  39.     /**
  40.      * @var string|null
  41.      *
  42.      * @ORM\Column(name="street", type="string", length=255, nullable=true)
  43.      */
  44.     private $street;
  45.     /**
  46.      * @var string|null
  47.      *
  48.      * @ORM\Column(name="opening_hr", type="string", length=255, nullable=true)
  49.      */
  50.     private $openingHr;
  51.     /**
  52.      * @var string|null
  53.      *
  54.      * @ORM\Column(name="www", type="string", length=255, nullable=true)
  55.      */
  56.     private $www;
  57.     /**
  58.      * @var string|null
  59.      *
  60.      * @ORM\Column(name="zip", type="string", length=255, nullable=true)
  61.      */
  62.     private $zip;
  63.     /**
  64.      * @var string|null
  65.      *
  66.      * @ORM\Column(name="sale_info", type="string", length=255, nullable=true)
  67.      */
  68.     private $saleInfo;
  69.     /**
  70.      * @var string|null
  71.      *
  72.      * @ORM\Column(name="personal_note", type="string", length=255, nullable=true)
  73.      */
  74.     private $personalNote;
  75.     /**
  76.      * @var string|null
  77.      *
  78.      * @ORM\Column(name="apigeo", type="string", length=255, nullable=true)
  79.      */
  80.     private $apigeo;
  81.     /**
  82.      * @var string|null
  83.      *
  84.      * @ORM\Column(name="apitime", type="string", length=255, nullable=true)
  85.      */
  86.     private $apitime;
  87.     /**
  88.      * @var bool
  89.      *
  90.      * @ORM\Column(name="is_active", type="boolean", nullable=false)
  91.      */
  92.     private $isActive;
  93.     /**
  94.      * @var bool
  95.      *
  96.      * @ORM\Column(name="is_deleted", type="boolean", nullable=false)
  97.      */
  98.     private $isDeleted;
  99.     /**
  100.      * @var string|null
  101.      *
  102.      * @ORM\Column(name="extent", type="string", length=45, nullable=true)
  103.      */
  104.     private $extent;
  105.     /**
  106.      * @var string|null
  107.      *
  108.      * @ORM\Column(name="extent_label", type="string", length=45, nullable=true)
  109.      */
  110.     private $extentLabel;
  111.     /**
  112.      * @var string|null
  113.      *
  114.      * @ORM\Column(name="yt_video", type="string", length=45, nullable=true)
  115.      */
  116.     private $ytVideo;
  117.     /**
  118.      * @var float|null
  119.      *
  120.      * @ORM\Column(name="latitude", type="float", precision=10, scale=0, nullable=true)
  121.      */
  122.     private $latitude;
  123.     /**
  124.      * @var float|null
  125.      *
  126.      * @ORM\Column(name="longitude", type="float", precision=10, scale=0, nullable=true)
  127.      */
  128.     private $longitude;
  129.     /**
  130.      * @var string|null
  131.      *
  132.      * @ORM\Column(name="sale_info_article", type="string", length=255, nullable=true)
  133.      */
  134.     private $saleInfoArticle;
  135.     /**
  136.      * @var \App\Entity\City
  137.      *
  138.      * @ORM\ManyToOne(targetEntity="App\Entity\City")
  139.      * @ORM\JoinColumns({
  140.      *   @ORM\JoinColumn(name="city", referencedColumnName="city_id")
  141.      * })
  142.      */
  143.     private $city;
  144.     /**
  145.      * @var \App\Entity\Shoppingarea
  146.      *
  147.      * @ORM\ManyToOne(targetEntity="App\Entity\Shoppingarea")
  148.      * @ORM\JoinColumns({
  149.      *   @ORM\JoinColumn(name="shopping_area", referencedColumnName="shoppingarea_id")
  150.      * })
  151.      */
  152.     private $shoppingArea;
  153.     /**
  154.      * @var Shoppingmall
  155.      *
  156.      * @ORM\ManyToOne(targetEntity="App\Entity\Shoppingmall")
  157.      * @ORM\JoinColumns({
  158.      *   @ORM\JoinColumn(name="shopping_mall", referencedColumnName="shoppingmall_id")
  159.      * })
  160.      */
  161.     private $shoppingMall;
  162.     /**
  163.      * @var \App\Entity\Shoptype
  164.      *
  165.      * @ORM\ManyToOne(targetEntity="App\Entity\Shoptype")
  166.      * @ORM\JoinColumns({
  167.      *   @ORM\JoinColumn(name="type", referencedColumnName="shoptype_id")
  168.      * })
  169.      */
  170.     private $type;
  171.     /**
  172.      * @var \Doctrine\Common\Collections\Collection
  173.      *
  174.      * @ORM\ManyToMany(targetEntity="App\Entity\Article", mappedBy="shops")
  175.      */
  176.     private $article;
  177.     /**
  178.      * @var \Doctrine\Common\Collections\Collection
  179.      *
  180.      * @ORM\ManyToMany(targetEntity="App\Entity\Brand", inversedBy="shops")
  181.      * @ORM\JoinTable(name="shop_has_brand",
  182.      *   joinColumns={
  183.      *     @ORM\JoinColumn(name="shop_id", referencedColumnName="shop_id")
  184.      *   },
  185.      *   inverseJoinColumns={
  186.      *     @ORM\JoinColumn(name="brand_id", referencedColumnName="brand_id")
  187.      *   }
  188.      * )
  189.      */
  190.     private $brands;
  191.     /**
  192.      * @var \Doctrine\ORM\PersistentCollection
  193.      *
  194.      * @ORM\OneToMany(targetEntity="App\Entity\ShopHasCategories", mappedBy="shop", cascade={"persist"})
  195.      */
  196.     private $shopHasCategories;
  197. //    /**
  198. //     * @var \Doctrine\Common\Collections\Collection
  199. //     *
  200. //     * @ORM\OneToMany(targetEntity="App\Entity\History", mappedBy="shop", fetch="EXTRA_LAZY")
  201. //     *
  202. //     */
  203. //    private $histories;
  204.     /**
  205.      * Created Date
  206.      * @var DateTime|null
  207.      *
  208.      * @ORM\Column(name="created_at", type="datetimetz", nullable=true)
  209.      */
  210.     private $createdAt;
  211.     /**
  212.      * Updated Date
  213.      * @var DateTime|null
  214.      *
  215.      * @ORM\Column(name="updated_at", type="datetimetz", nullable=true)
  216.      */
  217.     private $updatedAt;
  218.     /**
  219.      * @var \Doctrine\Common\Collections\Collection
  220.      *
  221.      * @ORM\ManyToMany(targetEntity="App\Entity\Shopkind", inversedBy="shops")
  222.      * @ORM\JoinTable(name="shop_has_shopkind",
  223.      *   joinColumns={
  224.      *     @ORM\JoinColumn(name="shop_id", referencedColumnName="shop_id")
  225.      *   },
  226.      *   inverseJoinColumns={
  227.      *     @ORM\JoinColumn(name="shopkind_id", referencedColumnName="shopkind_id")
  228.      *   }
  229.      * )
  230.      */
  231.     private $shopkinds;
  232.     /**
  233.      * @ORM\Column(type="boolean", nullable=true)
  234.      */
  235.     private $isNew;
  236.     /**
  237.      * @ORM\Column(type="date", nullable=true)
  238.      */
  239.     private $isNewDate;
  240.     /**
  241.      * @ORM\OneToOne(targetEntity="App\Entity\CompanyHasShop", mappedBy="shop")
  242.      */
  243.     private $companyHasShop;
  244.     /**
  245.      * Constructor
  246.      */
  247.     public function __construct()
  248.     {
  249.         $this->brands = new \Doctrine\Common\Collections\ArrayCollection();
  250.         $this->histories = new \Doctrine\Common\Collections\ArrayCollection();
  251.         $this->shopHasCategories = new \Doctrine\Common\Collections\ArrayCollection();
  252.         $this->shopkinds = new \Doctrine\Common\Collections\ArrayCollection();
  253.     }
  254.     /**
  255.      * @param $name
  256.      * @return mixed
  257.      */
  258.     public function __get($name)
  259.     {
  260.         if (property_exists($this$name)) {
  261.             return $this->$name;
  262.         } else {
  263.             return null;
  264.         }
  265.     }
  266.     /************************************************************************************************************/
  267.     /****** COLLECTIONS METHODS *********************************************************************************/
  268.     /************************************************************************************************************/
  269.     /**
  270.      * @param \App\Entity\Brand $brand
  271.      * @return bool
  272.      */
  273.     public function addBrand(Brand $brand)
  274.     {
  275.         return $this->brands->add($brand);
  276.     }
  277.     public function removeBrand(Brand $brand)
  278.     {
  279.         return $this->brands->remove($brand);
  280.     }
  281.     /**
  282.      * @param Category $category
  283.      * @param null $isPrimary
  284.      * @return $this|false
  285.      */
  286.     public function addCategory(Category $category$isPrimary null)
  287.     {
  288.         if(false === $this->hasCategory($category)){
  289.             $shopHasCategory = new ShopHasCategories();
  290.             $shopHasCategory->setCategory($category);
  291.             $shopHasCategory->setShop($this);
  292.             if($isPrimary === true){
  293.                 $this->clearPrimaryCategory();
  294.                 $shopHasCategory->setIsPrimary(true);
  295.             }
  296.             $this->shopHasCategories->add($shopHasCategory);
  297.             return $this;
  298.         }
  299.         return false;
  300.     }
  301.     /**
  302.      * @param Category $category
  303.      * @return bool
  304.      */
  305.     public function removeCategory(Category $category)
  306.     {
  307.         if(true === $this->hasCategory($category)){
  308.             $shopHasCategoryForDelete null;
  309.             /** @var ShopHasCategories $shopHasCategory */
  310.             foreach($this->shopHasCategories as $shopHasCategory){
  311.                 if($shopHasCategory->getCategory()->getId() === $category->getId()){
  312.                     $shopHasCategoryForDelete $shopHasCategory;
  313.                 }
  314.             }
  315.             $this->shopHasCategories->removeElement($shopHasCategoryForDelete);
  316.             return true;
  317.         }
  318.         return false;
  319.     }
  320.     /**
  321.      *
  322.      */
  323.     public function clearPrimaryCategory(){
  324.         /** @var ShopHasCategories $shopHasCategory */
  325.         foreach ($this->shopHasCategories as $shopHasCategory) {
  326.             $shopHasCategory->setIsPrimary(false);
  327.         }
  328.     }
  329.     /**
  330.      * @param \App\Entity\Shopkind $shopkind
  331.      * @return bool
  332.      */
  333.     public function addShopkind(Shopkind $shopkind)
  334.     {
  335.         return $this->shopkinds->add($shopkind);
  336.     }
  337.     /**
  338.      * @param \App\Entity\Shopkind $shopkind
  339.      * @return bool
  340.      */
  341.     public function removeShopkind(Shopkind $shopkind)
  342.     {
  343.         return $this->shopkinds->remove($shopkind);
  344.     }
  345.     /**
  346.      * @return \Doctrine\Common\Collections\Collection|\App\Entity\Brand[]
  347.      */
  348.     public function getBrands(): \Doctrine\Common\Collections\Collection
  349.     {
  350.         return $this->brands;
  351.     }
  352.     /**
  353.      * @return \Doctrine\Common\Collections\Collection|\App\Entity\History[]
  354.      */
  355.     public function getHistories(): ?\Doctrine\Common\Collections\Collection
  356.     {
  357.         return $this->histories;
  358.     }
  359.     /**
  360.      * @return Collection
  361.      */
  362.     public function getShopHasCategories(): Collection
  363.     {
  364.         return $this->shopHasCategories;
  365.     }
  366.     /**
  367.      * @return \Doctrine\Common\Collections\Collection|\App\Entity\Shopkind[]
  368.      */
  369.     public function getShopkinds(): Collection
  370.     {
  371.         return $this->shopkinds;
  372.     }
  373.     /**
  374.      * @param $shopkinds \Doctrine\Common\Collections\Collection|\App\Entity\Shopkind[]
  375.      */
  376.     public function setShopkinds($shopkinds): void
  377.     {
  378.         $this->shopkinds $shopkinds;
  379.     }
  380.     /**
  381.      * @return array
  382.      */
  383.     protected function getShopkindsStrings()
  384.     {
  385.         $return = [];
  386.         foreach ($this->getShopkinds() as $shopkind) {
  387.             $return[] = (string)$shopkind;
  388.         }
  389.         return $return;
  390.     }
  391.     /**
  392.      * @return array
  393.      */
  394.     protected function getShopHasCategoriesStrings()
  395.     {
  396.         $return = [];
  397.         foreach ($this->getShopHasCategories() as $shopHasCategory) {
  398.             $return[] = (string)$shopHasCategory;
  399.         }
  400.         return $return;
  401.     }
  402.     /************************************************************************************************************/
  403.     /****** GETTERS & SETTERS ***********************************************************************************/
  404.     /************************************************************************************************************/
  405.     /**
  406.      * @return int|null
  407.      */
  408.     public function getId(): ?int
  409.     {
  410.         return $this->id;
  411.     }
  412.     /**
  413.      * @return string
  414.      */
  415.     public function getMongoId(): ?string
  416.     {
  417.         return $this->_id;
  418.     }
  419.     /**
  420.      * @return string
  421.      */
  422.     public function getName(): ?string
  423.     {
  424.         return $this->name;
  425.     }
  426.     /**
  427.      * @param string $name
  428.      */
  429.     public function setName(string $name): void
  430.     {
  431.         $this->name $name;
  432.     }
  433.     /**
  434.      * @return string|null
  435.      */
  436.     public function getStreet(): ?string
  437.     {
  438.         return $this->street;
  439.     }
  440.     /**
  441.      * @param string|null $street
  442.      */
  443.     public function setStreet(?string $street): void
  444.     {
  445.         $this->street $street;
  446.     }
  447.     /**
  448.      * @return string|null
  449.      */
  450.     public function getOpeningHr(): ?string
  451.     {
  452.         return $this->openingHr;
  453.     }
  454.     /**
  455.      * @param string|null $openingHr
  456.      */
  457.     public function setOpeningHr(?string $openingHr): void
  458.     {
  459.         $this->openingHr $openingHr;
  460.     }
  461.     /**
  462.      * @return string|null
  463.      */
  464.     public function getWww(): ?string
  465.     {
  466.         return $this->www;
  467.     }
  468.     /**
  469.      * @param string|null $www
  470.      */
  471.     public function setWww(?string $www): void
  472.     {
  473.         $this->www $www;
  474.     }
  475.     /**
  476.      * @return string|null
  477.      */
  478.     public function getZip(): ?string
  479.     {
  480.         return $this->zip;
  481.     }
  482.     /**
  483.      * @param string|null $zip
  484.      */
  485.     public function setZip(?string $zip): void
  486.     {
  487.         $this->zip $zip;
  488.     }
  489.     /**
  490.      * @return string|null
  491.      */
  492.     public function getSaleInfo(): ?string
  493.     {
  494.         return $this->saleInfo;
  495.     }
  496.     /**
  497.      * @param string|null $saleInfo
  498.      */
  499.     public function setSaleInfo(?string $saleInfo): void
  500.     {
  501.         $this->saleInfo $saleInfo;
  502.     }
  503.     /**
  504.      * @return string|null
  505.      */
  506.     public function getPersonalNote(): ?string
  507.     {
  508.         return $this->personalNote;
  509.     }
  510.     /**
  511.      * @param string|null $personalNote
  512.      */
  513.     public function setPersonalNote(?string $personalNote): void
  514.     {
  515.         $this->personalNote $personalNote;
  516.     }
  517.     /**
  518.      * @return string|null
  519.      */
  520.     public function getApigeo(): ?string
  521.     {
  522.         return $this->apigeo;
  523.     }
  524.     /**
  525.      * @param string|null $apigeo
  526.      */
  527.     public function setApigeo(?string $apigeo): void
  528.     {
  529.         $this->apigeo $apigeo;
  530.     }
  531.     /**
  532.      * @return string|null
  533.      */
  534.     public function getApitime(): ?string
  535.     {
  536.         return $this->apitime;
  537.     }
  538.     /**
  539.      * @param string|null $apitime
  540.      */
  541.     public function setApitime(?string $apitime): void
  542.     {
  543.         $this->apitime $apitime;
  544.     }
  545.     /**
  546.      * @return bool
  547.      */
  548.     public function isActive(): bool
  549.     {
  550.         return (boolean)$this->isActive;
  551.     }
  552.     /**
  553.      * @param bool $isActive
  554.      */
  555.     public function setIsActive(bool $isActive): void
  556.     {
  557.         $this->isActive $isActive;
  558.     }
  559.     /**
  560.      * @return bool
  561.      */
  562.     public function isDeleted(): bool
  563.     {
  564.         return (boolean)$this->isDeleted;
  565.     }
  566.     /**
  567.      * @param bool $isDeleted
  568.      */
  569.     public function setIsDeleted(bool $isDeleted): void
  570.     {
  571.         $this->isDeleted $isDeleted;
  572.     }
  573.     /**
  574.      * @return string|null
  575.      */
  576.     public function getExtent(): ?string
  577.     {
  578.         return $this->extent;
  579.     }
  580.     /**
  581.      * @param string|null $extent
  582.      */
  583.     public function setExtent(?string $extent): void
  584.     {
  585.         $this->extent $extent;
  586.     }
  587.     /**
  588.      * @return string|null
  589.      */
  590.     public function getExtentLabel(): ?string
  591.     {
  592.         return $this->extentLabel;
  593.     }
  594.     /**
  595.      * @param string|null $extentLabel
  596.      */
  597.     public function setExtentLabel(?string $extentLabel): void
  598.     {
  599.         $this->extentLabel $extentLabel;
  600.     }
  601.     /**
  602.      * @return string|null
  603.      */
  604.     public function getYtVideo(): ?string
  605.     {
  606.         return $this->ytVideo;
  607.     }
  608.     /**
  609.      * @param string|null $ytVideo
  610.      */
  611.     public function setYtVideo(?string $ytVideo): void
  612.     {
  613.         $this->ytVideo $ytVideo;
  614.     }
  615.     /**
  616.      * @return float|null
  617.      */
  618.     public function getLatitude(): ?float
  619.     {
  620.         $shoppingmall $this->getShoppingMall();
  621.         if(isset($shoppingmall)){
  622.             return $shoppingmall->getLatitude();
  623.         }
  624.         return $this->latitude;
  625.     }
  626.     /**
  627.      * @param float|null $latitude
  628.      */
  629.     public function setLatitude(?float $latitude): void
  630.     {
  631.         $this->latitude $latitude;
  632.     }
  633.     /**
  634.      * @return float|null
  635.      */
  636.     public function getLongitude(): ?float
  637.     {
  638.         $shoppingmall $this->getShoppingMall();
  639.         if(isset($shoppingmall)){
  640.             return $shoppingmall->getLongitude();
  641.         }
  642.         return $this->longitude;
  643.     }
  644.     /**
  645.      * @param float|null $longitude
  646.      */
  647.     public function setLongitude(?float $longitude): void
  648.     {
  649.         $this->longitude $longitude;
  650.     }
  651.     /**
  652.      * @return string|null
  653.      */
  654.     public function getSaleInfoArticle(): ?string
  655.     {
  656.         return $this->saleInfoArticle;
  657.     }
  658.     /**
  659.      * @param string|null $saleInfoArticle
  660.      */
  661.     public function setSaleInfoArticle(?string $saleInfoArticle): void
  662.     {
  663.         $this->saleInfoArticle $saleInfoArticle;
  664.     }
  665.     /**
  666.      * @return \App\Entity\City
  667.      */
  668.     public function getCity(): ?\App\Entity\City
  669.     {
  670.         return $this->city;
  671.     }
  672.     /**
  673.      * @param \App\Entity\City $city
  674.      */
  675.     public function setCity(\App\Entity\City $city): void
  676.     {
  677.         $this->city $city;
  678.     }
  679.     /**
  680.      * @return \App\Entity\Shoppingarea
  681.      */
  682.     public function getShoppingArea(): ?\App\Entity\Shoppingarea
  683.     {
  684.         return $this->shoppingArea;
  685.     }
  686.     /**
  687.      * @param \App\Entity\Shoppingarea $shoppingArea
  688.      */
  689.     public function setShoppingArea(\App\Entity\Shoppingarea $shoppingArea): void
  690.     {
  691.         $this->shoppingArea $shoppingArea;
  692.     }
  693.     /**
  694.      * @return \App\Entity\Shoppingmall
  695.      */
  696.     public function getShoppingMall()
  697.     {
  698.         return $this->shoppingMall;
  699.     }
  700.     /**
  701.      * @param \App\Entity\Shoppingmall $shoppingMall
  702.      */
  703.     public function setShoppingMall(\App\Entity\Shoppingmall $shoppingMall): void
  704.     {
  705.         $this->shoppingMall $shoppingMall;
  706.     }
  707.     /**
  708.      * @return \App\Entity\Shoptype
  709.      */
  710.     public function getType(): ?\App\Entity\Shoptype
  711.     {
  712.         return $this->type;
  713.     }
  714.     /**
  715.      * @param \App\Entity\Shoptype $type
  716.      */
  717.     public function setType(\App\Entity\Shoptype $type): void
  718.     {
  719.         $this->type $type;
  720.     }
  721.     /**
  722.      * Return data in array. Used by REST API
  723.      *
  724.      * @return array
  725.      */
  726.     public function toArray($onlyValue false)
  727.     {
  728.         $return = [
  729.             'id' => $this->getId(),
  730.             'name' => $this->getName(),
  731.             'type' => (string)$this->getType(),
  732.             'brands' => count($this->getBrands()),
  733.             'shopkinds' => implode(', '$this->getShopkindsStrings()),
  734.             'categories' => implode(', '$this->getShopHasCategoriesStrings()),
  735.             'street' => $this->getStreet(),
  736.             'city' => (string)$this->getCity(),
  737.             'shoppingMall' => (string)$this->getShoppingMall(),
  738.             'zip' => $this->getZip(),
  739.             'extent' => $this->getExtent(),
  740.             'extentLabel' => $this->getExtentLabel(),
  741.             'shoppingArea' => (string)$this->getShoppingArea(),
  742.             'www' => $this->getWww(),
  743.             'openingHr' => $this->getOpeningHr(),
  744.             'isNew' => $this->getIsNew(),
  745.             'latitude' => $this->getLatitude(),
  746.             'longitude' => $this->getLongitude(),
  747.             'apigeo' => $this->getApigeo(),
  748.             'apitime' => $this->getApitime(),
  749.         ];
  750.         if ($onlyValue) {
  751.             return array_values($return);
  752.         } else {
  753.             return $return;
  754.         }
  755.     }
  756.     public function __toString()
  757.     {
  758.         return '('.$this->getId().') - '.$this->getName();
  759.     }
  760.     public function getIsNew(): ?bool
  761.     {
  762.         return $this->isNew;
  763.     }
  764.     public function setIsNew(?bool $isNew): self
  765.     {
  766.         $this->isNew $isNew;
  767.         return $this;
  768.     }
  769.     public function getIsNewDate(): ?\DateTimeInterface
  770.     {
  771.         return $this->isNewDate;
  772.     }
  773.     public function setIsNewDate(?\DateTimeInterface $isNewDate): self
  774.     {
  775.         $this->isNewDate $isNewDate;
  776.         return $this;
  777.     }
  778.     /**
  779.      * @return \App\Entity\Category|null
  780.      */
  781.     public function getPrimaryCategory()
  782.     {
  783.         /** @var \App\Entity\ShopHasCategories $shopHasCategory */
  784.         foreach ($this->shopHasCategories as $shopHasCategory) {
  785.             if ($shopHasCategory->isPrimary()) {
  786.                 return $shopHasCategory->getCategory();
  787.             }
  788.         }
  789.     }
  790.     /**
  791.      * @param Category $category
  792.      *
  793.      * @return bool
  794.      */
  795.     public function setPrimaryCategory(Category $category)
  796.     {
  797.         if($this->hasCategory($category)){
  798.             /** @var ShopHasCategories $shopHasCategory */
  799.             foreach ($this->shopHasCategories as $shopHasCategory) {
  800.                 if($shopHasCategory->getCategory()->getId() == $category->getId()){
  801.                     $shopHasCategory->setIsPrimary(true);
  802.                 }else{
  803.                     $shopHasCategory->setIsPrimary(false);
  804.                 }
  805.             }
  806.         }
  807.         return false;
  808.     }
  809.     /**
  810.      * @param Category $category
  811.      * @return bool
  812.      */
  813.     public function hasCategory(Category $category)
  814.     {
  815.         /** @var \App\Entity\ShopHasCategories $shopHasCategory */
  816.         foreach ($this->shopHasCategories as $shopHasCategory) {
  817.             if($shopHasCategory->getCategory()->getId() === $category->getId()){
  818.                 return true;
  819.             }
  820.         }
  821.         return false;
  822.     }
  823.     /**
  824.      * @return \App\Entity\Company|null
  825.      */
  826.     public function getCompany()
  827.     {
  828. //        $chs = $this->getCompanyHasShop();
  829. //        if(is_null($chs)){
  830. //            return $chs->getCompany();
  831. //        }
  832.         return null;
  833.     }
  834.     /**
  835.      * @param \App\Entity\Company $company
  836.      * @return $this
  837.      * @throws \Exception
  838.      */
  839.     public function setCompany(Company $company): self
  840.     {
  841.         throw new Exception('Method is deprecated. Please use setCompanyHasShop method');
  842.     }
  843.     /**
  844.      * @return CompanyHasShop|null
  845.      */
  846.     public function getCompanyHasShop(): ?Collection
  847.     {
  848.         return $this->companyHasShop;
  849.     }
  850.     /**
  851.      * @param $companyHasShop
  852.      * @return $this
  853.      */
  854.     public function setCompanyHasShop($companyHasShop): self
  855.     {
  856.         $this->companyHasShop $companyHasShop;
  857.         return $this;
  858.     }
  859.     /**
  860.      * @return DateTime|null
  861.      */
  862.     public function getCreatedAt(): ?\DateTime
  863.     {
  864.         return $this->createdAt;
  865.     }
  866.     /**
  867.      * @param string|null $createdAt
  868.      */
  869.     public function setCreatedAt(?string $createdAt): void
  870.     {
  871.         $this->createdAt $createdAt;
  872.     }
  873.     /**
  874.      * @return \DateTime|null
  875.      */
  876.     public function getUpdatedAt(): ?\DateTime
  877.     {
  878.         return $this->updatedAt;
  879.     }
  880.     /**
  881.      * @param string|null $updatedAt
  882.      */
  883.     public function setUpdatedAt(?string $updatedAt): void
  884.     {
  885.         $this->updatedAt $updatedAt;
  886.     }
  887. }