src/Entity/Offer/Offer.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Offer;
  3. use App\Entity\Application;
  4. use App\Entity\Item\Item;
  5. use App\Entity\Order\Orders;
  6. use App\Entity\Package\Package;
  7. use App\Entity\SharedOffer;
  8. use App\Entity\Traits\IdTrait;
  9. use App\Entity\Traits\TimeStampAbleTrait;
  10. use App\Entity\User\User;
  11. use App\Utils\Slug\Slug;
  12. use App\Utils\UniqShortUuid\shortUuid;
  13. use DateTime;
  14. use Doctrine\Common\Collections\ArrayCollection;
  15. use Doctrine\Common\Collections\Collection;
  16. use Doctrine\ORM\EntityManagerInterface;
  17. use Ramsey\Uuid\Uuid;
  18. use Symfony\Contracts\Translation\TranslatorInterface;
  19. use App\Repository\Offer\OfferRepository;
  20. use Doctrine\ORM\Mapping as ORM;
  21. /**
  22.  * @ORM\Entity(repositoryClass=OfferRepository::class)
  23.  * @ORM\HasLifecycleCallbacks
  24.  */
  25. class Offer
  26. {
  27.     use IdTrait;
  28.     use TimeStampAbleTrait;
  29.     public const STATUS_GREEN = 'text-success';
  30.     public const STATUS_RED = 'text-alert';
  31.     const ZERO  = 0;
  32.     const ONE   = 1;
  33.     const TWO   = 2;
  34.     const THREE = 3;
  35.     const FOUR  = 4;
  36.     const FIVE  = 5;
  37.     const SIX   = 6;
  38.     const SEVEN = 7;
  39.     /**
  40.      * @ORM\OneToMany(targetEntity=OfferItem::class, mappedBy="offer")
  41.      */
  42.     private $offerItems;
  43.     /**
  44.      * @ORM\OneToOne(targetEntity=OfferCompany::class)
  45.      */
  46.     private ?OfferCompany $offerCompany = null;
  47.      /**
  48.      * @ORM\Column(type="json", nullable="true")
  49.      */
  50.     private ?array $searchParams = [];
  51.     /**
  52.      * @ORM\Column(type="string", length="255", nullable="true")
  53.      */
  54.     private ?string $offerNamePL = '';
  55.     /**
  56.      * @ORM\Column(type="string", length="255", nullable="true")
  57.      */
  58.     private ?string $offerNameEN = '';
  59.     /**
  60.      * @ORM\Column(type="string", length="255", nullable="true")
  61.      */
  62.     private ?string $offerLevelPL = '';
  63.     /**
  64.      * @ORM\Column(type="string", length="255", nullable="true")
  65.      */
  66.     private ?string $offerLevelEN = '';
  67.     /**
  68.      * @ORM\Column(type="datetime", nullable=true)
  69.      */
  70.     private ?DateTime $publishedAt;
  71.     /**
  72.      * @ORM\Column(type="datetime", nullable=true, options={"default" : null})
  73.      */
  74.     private ?DateTime $boostDate;
  75.     /**
  76.      * @ORM\Column(type="datetime", nullable=true)
  77.      */
  78.     private ?DateTime $activeUntil;
  79.     /**
  80.      * @ORM\Column(type="datetime", nullable=true)
  81.      */
  82.     private ?DateTime $updateInsteps;
  83.     /**
  84.      * @ORM\OneToMany(targetEntity=Application::class, mappedBy="offer")
  85.      * @ORM\JoinColumn(nullable=true)
  86.      */
  87.     private $application;
  88.     /**
  89.      * @ORM\OneToMany(targetEntity=OfferLinkList::class, mappedBy="offer")
  90.      */
  91.     private $offerLinkList;
  92.     /**
  93.      * @ORM\Column(type="string", length=255, nullable=true)
  94.      */
  95.     private $shortOfferCode;
  96.     /**
  97.      * @ORM\OneToMany(targetEntity=SharedOffer::class, mappedBy="offer")
  98.      */
  99.     private $sharedOffers;
  100.     /**
  101.      * @ORM\Column(type="string", length=255, nullable=true)
  102.      */
  103.     private $creator;
  104.     /**
  105.      * @ORM\Column(type="string", length=255, nullable=true)
  106.      */
  107.     private $language;
  108.     /**
  109.      * @ORM\Column(type="integer", nullable=true)
  110.      */
  111.     private $numberOfInsteps;
  112.     /**
  113.      * @ORM\ManyToOne(targetEntity=Package::class)
  114.      */
  115.     private ?Package $package;
  116.     /**
  117.      * @ORM\ManyToOne(targetEntity=Offer::class, inversedBy="offers")
  118.      */
  119.     private ?Offer $offer;
  120.     /**
  121.      * @ORM\OneToMany(targetEntity=Offer::class, mappedBy="offer", cascade={"persist","remove","refresh"})
  122.      */
  123.     private $offers;
  124.     /**
  125.      * @ORM\ManyToOne(targetEntity=Orders::class)
  126.      */
  127.     private ?Orders $order;
  128.     /**
  129.      * @ORM\Column(type="text", nullable=true)
  130.      */
  131.     private ?string $keywords;
  132.     /**
  133.      * @ORM\Column(type="boolean")
  134.      */
  135.     private bool $visible;
  136.     public function __construct(
  137.         /**
  138.          * @ORM\Column(type="string", length="255", nullable="true")
  139.          */
  140.         private ?string $temporaryId,
  141.         /**
  142.          * @ORM\Column(type="boolean", nullable=true)
  143.          */
  144.         private ?bool $done,
  145.         /**
  146.          * @ORM\Column(type="boolean", nullable=true)
  147.          */
  148.         private ?bool $active,
  149.         /**
  150.          * @ORM\Column(type="string", length="255", nullable="true")
  151.          */
  152.         private ?string $step,
  153.         /**
  154.          * @ORM\Column(type="string", length="255", nullable="true")
  155.          */
  156.         private ?string $email,
  157.         /**
  158.          * @ORM\Column(type="string", length="255", nullable="true")
  159.          */
  160.         private ?string $categoryId,
  161.         /**
  162.          * @ORM\ManyToOne(targetEntity=User::class)
  163.          */
  164.         private ?User $user,
  165.         /**
  166.          * @ORM\Column(type="integer", nullable="true")
  167.          */
  168.         private ?int $numberOfApplication,
  169.         /**
  170.          * @ORM\Column(type="string", length="255", nullable="true")
  171.          */
  172.         private ?string $accessKey,
  173.         /**
  174.          * @ORM\Column(type="json", nullable="true")
  175.          */
  176.         private ?array $salaryData,
  177.         /**
  178.          * @ORM\Column(type="json", nullable="true")
  179.          */
  180.         private ?array $workData,
  181.     ){
  182.         $this->offerItems = new ArrayCollection();
  183.         $this->application = new ArrayCollection();
  184.         $this->offerLinkList = new ArrayCollection();
  185.         $this->sharedOffers = new ArrayCollection();
  186.         $this->offer_search = new ArrayCollection();
  187.         $this->visible = true;
  188.     }
  189.     public function __clone()
  190.     {
  191.         $this->id                   = null;
  192.         $this->offerCompany         = null;
  193.         $this->temporaryId          = null;
  194.         $this->numberOfApplication  = null;
  195.         $this->shortOfferCode       = null;
  196.         $this->done                 = null;
  197.         $this->active               = false;
  198.     }
  199.     public function cloneObject(?OfferCompany $offerCompany): self
  200.     {
  201.         $clone = clone $this;
  202.         $clone->offerCompany        = $offerCompany;
  203.         $clone->temporaryId         = Uuid::uuid4()->toString();
  204.         $clone->numberOfApplication = 0;
  205.         $clone->shortOfferCode      = shortUuid::shortUuid();
  206.         $clone->done                = false;
  207.         $clone->active              = false;
  208.         return $clone;
  209.     }
  210.     public function cloneChild(
  211.         ?OfferCompany $offerCompany,
  212.         int $key,
  213.         ?Offer $mainOffer,
  214.     ): self
  215.     {
  216.         $clone = clone $this;
  217.         $clone->offerCompany = $offerCompany;
  218.         $clone->temporaryId  = Uuid::uuid4()->toString();
  219.         $clone->numberOfApplication = 0;
  220.         $clone->shortOfferCode = shortUuid::shortUuid();
  221.         $clone->publishedAt = new DateTime();
  222.         $clone->done = $mainOffer ? $mainOffer->getDone() : false;
  223.         $clone->active = $mainOffer ? $mainOffer->getActive() : false;
  224.         $clone->childData = [];
  225.         $offerWorkData = $clone->getWorkData();
  226.         $offerSearchParams = $clone->getSearchParams();
  227.         $this->createWorkDataWithKey($offerWorkData, $key);
  228.         $this->createSearchParamsWithKey($offerWorkData, $offerSearchParams, $key);
  229.         $clone->setWorkData($offerWorkData);
  230.         $clone->setSearchParams($offerSearchParams);
  231.         if(is_null($mainOffer) === false){
  232.             $clone->setOffer($mainOffer);
  233.         }
  234.         return $clone;
  235.     }
  236.     public function addOfferItemsToOffer(Offer $offer, array $offerItems): void
  237.     {
  238.         foreach($offerItems as $offerItem){
  239.             $offer->addItem($offerItem);
  240.         }
  241.     }
  242.     /**
  243.      * @return DateTime|null
  244.      */
  245.     public function getBoostDate(): ?DateTime
  246.     {
  247.         return $this->boostDate;
  248.     }
  249.     /**
  250.      * @param DateTime|null $boostDate
  251.      */
  252.     public function setBoostDate(?DateTime $boostDate): void
  253.     {
  254.         $this->boostDate = $boostDate;
  255.     }
  256.     /**
  257.      * @return string|null
  258.      */
  259.     public function getEmail(): ?string
  260.     {
  261.         return $this->email;
  262.     }
  263.     /**
  264.      * @param string|null $email
  265.      */
  266.     public function setEmail(?string $email): void
  267.     {
  268.         $this->email = $email;
  269.     }
  270.     /**
  271.      * @return OfferCompany|null
  272.      */
  273.     public function getOfferCompany(): ?OfferCompany
  274.     {
  275.         return $this->offerCompany;
  276.     }
  277.     /**
  278.      * @param OfferCompany|null $offerCompany
  279.      */
  280.     public function setOfferCompany(?OfferCompany $offerCompany): void
  281.     {
  282.         $this->offerCompany = $offerCompany;
  283.     }
  284.     /**
  285.      * @return Collection
  286.      */
  287.     public function getOfferItems(): Collection
  288.     {
  289.         return $this->offerItems;
  290.     }
  291.     public function addItem(OfferItem $offerItem): self
  292.     {
  293.         if(!$this->offerItems->contains($offerItem)){
  294.             $this->offerItems[] = $offerItem;
  295.             $offerItem->setOffer($this);
  296.         }
  297.         return $this;
  298.     }
  299.     public function removeItem(OfferItem $offerItem): self
  300.     {
  301.         if ($this->offerItems->removeElement($offerItem)) {
  302.             // set the owning side to null (unless already changed)
  303.             if ($offerItem->getOffer() === $this) {
  304.                 $offerItem->setOffer(null);
  305.             }
  306.         }
  307.         return $this;
  308.     }
  309.     /**
  310.      * @return array|null
  311.      */
  312.     public function getSalaryData(): ?array
  313.     {
  314.         return $this->salaryData;
  315.     }
  316.     /**
  317.      * @param array|null $salaryData
  318.      */
  319.     public function setSalaryData(?array $salaryData): self
  320.     {
  321.         $this->salaryData = $salaryData;
  322.         return $this;
  323.     }
  324.     /**
  325.      * @return array|null
  326.      */
  327.     public function getWorkData(): ?array
  328.     {
  329.         return $this->workData;
  330.     }
  331.     /**
  332.      * @param array|null $workData
  333.      */
  334.     public function setWorkData(?array $workData): self
  335.     {
  336.         $this->workData = $workData;
  337.         return $this;
  338.     }
  339.     public function getOffer(): ?Offer
  340.     {
  341.         return $this->offer;
  342.     }
  343.     public function setOffer(?Offer $offer): self
  344.     {
  345.         $this->offer = $offer;
  346.         return $this;
  347.     }
  348.     public function getOffers()
  349.     {
  350.         return $this->offers;
  351.     }
  352.     public function addOffers(Offer $offer): self
  353.     {
  354.         if (!$this->offers->contains($offer)) {
  355.             $this->offers[] = $offer;
  356.             $offer->setOffer($this);
  357.         }
  358.         return $this;
  359.     }
  360.     public function removeOffers(Offer $offer): self
  361.     {
  362.         if ($this->offers->removeElement($offer)) {
  363.             if ($offer->getOffer() === $this) {
  364.                 $offer->setOffer(null);
  365.             }
  366.         }
  367.         return $this;
  368.     }
  369.     public function changeChildOffersActive(bool $active): void
  370.     {
  371.         foreach ($this->getOffers() as $offer) {
  372.             $offer->setActive($active);
  373.         }
  374.     }
  375.     public function changeChildOffersPublishedAt(DateTime $publishedAt): void
  376.     {
  377.         if (false === $this->isMainOffer()) {
  378.             return;
  379.         }
  380.         foreach ($this->getOffers() as $offer) {
  381.             $offer->setPublishedAt($publishedAt);
  382.         }
  383.     }
  384.     
  385.      /**
  386.      * @return array|null
  387.      */
  388.     public function getSearchParams(): ?array
  389.     {
  390.         return $this->searchParams;
  391.     }
  392.     /**
  393.      * @param array|null $workData
  394.      */
  395.     public function setSearchParams(?array $searchParams): self
  396.     {
  397.         $this->searchParams = $searchParams;
  398.         return $this;
  399.     }
  400.     /**
  401.      * @return string|null
  402.      */
  403.     public function getTemporaryId(): ?string
  404.     {
  405.         return $this->temporaryId;
  406.     }
  407.     /**
  408.      * @param string|null $temporaryId
  409.      */
  410.     public function setTemporaryId(?string $temporaryId): self
  411.     {
  412.         $this->temporaryId = $temporaryId;
  413.         return $this;
  414.     }
  415.     /**
  416.      * @return bool|null
  417.      */
  418.     public function getDone(): ?bool
  419.     {
  420.         return $this->done;
  421.     }
  422.     /**
  423.      * @param bool|null $done
  424.      */
  425.     public function setDone(?bool $done): self
  426.     {
  427.         $this->done = $done;
  428.         return $this;
  429.     }
  430.     /**
  431.      * @return bool|null
  432.      */
  433.     public function getActive(): ?bool
  434.     {
  435.         return $this->active;
  436.     }
  437.     /**
  438.      * @param bool|null $active
  439.      */
  440.     public function setActive(?bool $active): self
  441.     {
  442.         $this->active = $active;
  443.         return $this;
  444.     }
  445.     /**
  446.      * @return string|null
  447.      */
  448.     public function getStep(): ?string
  449.     {
  450.         return $this->step;
  451.     }
  452.     /**
  453.      * @param string|null $step
  454.      */
  455.     public function setStep(?string $step): self
  456.     {
  457.         $this->step = $step;
  458.         return $this;
  459.     }
  460.     /**
  461.      * @return string|null
  462.      */
  463.     public function getCategoryId(): ?string
  464.     {
  465.         return $this->categoryId;
  466.     }
  467.     /**
  468.      * @param string|null $categoryId
  469.      */
  470.     public function setCategoryId(?string $categoryId): self
  471.     {
  472.         $this->categoryId = $categoryId;
  473.         return $this;
  474.     }
  475.     /**
  476.      * @return string|null
  477.      */
  478.     public function getOfferNamePL(): ?string
  479.     {
  480.         return $this->offerNamePL;
  481.     }
  482.     /**
  483.      * @param string|null $offerNamePL
  484.      */
  485.     public function setOfferNamePL(?string $offerNamePL): self
  486.     {
  487.         $this->offerNamePL = $offerNamePL;
  488.         return $this;
  489.     }
  490.     /**
  491.      * @return string|null
  492.      */
  493.     public function getOfferNameEN(): ?string
  494.     {
  495.         return $this->offerNameEN;
  496.     }
  497.     /**
  498.      * @param string|null $offerNameEN
  499.      */
  500.     public function setOfferNameEN(?string $offerNameEN): self
  501.     {
  502.         $this->offerNameEN = $offerNameEN;
  503.         return $this;
  504.     }
  505.     /**
  506.      * @return int|null
  507.      */
  508.     public function getNumberOfApplication(): ?int
  509.     {
  510.         return $this->numberOfApplication;
  511.     }
  512.     /**
  513.      * @param int|null $numberOfApplication
  514.      */
  515.     public function setNumberOfApplication(?int $numberOfApplication): self
  516.     {
  517.         $this->numberOfApplication = $numberOfApplication;
  518.         return $this;
  519.     }
  520.     public function getCreatedAtAsString(): ?string
  521.     {
  522.         return $this->createdAt->format('d.m.Y');
  523.     }
  524.     public function getActiveUntil(): ?DateTime
  525.     {
  526.         return $this->activeUntil;
  527.     }
  528.     public function setActiveUntil(?DateTime $activeUntil): self
  529.     {
  530.         $this->activeUntil = $activeUntil;
  531.         return $this;
  532.     }
  533.     public function getPublishedAtAsString(): ?string
  534.     {
  535.         if(is_null($this->publishedAt)){ return null; }
  536.         return $this->publishedAt->format('d.m.Y');
  537.     }
  538.     public function getOfferCompanyName(): ?string
  539.     {
  540.         $companyData = $this->getOfferCompany();
  541.         if(is_null($companyData)) { return null; }
  542.         $invoiceData = $companyData->getInvoiceData();
  543.         if(is_null($invoiceData)){ return null; }
  544.         return $invoiceData->getName();
  545.     }
  546.     public function getCityNameFromWorkData(): ?string
  547.     {
  548.         $response = '';
  549.         $workData = $this->getWorkData();
  550.         if(is_null($workData)){ return null; }
  551.         if(false === isset($workData['address'])){ return null; }
  552.         if(false === isset($workData['address']['city'])){ return null; };
  553.         if(is_array($workData['address']['city'])){
  554.             $lastKey = count($workData['address']['city']);
  555.             foreach ($workData['address']['city'] as $key =>  $city){
  556.                 if($lastKey !== $key + 1){
  557.                     $response .= $city.', ';
  558.                 }else{
  559.                     $response .= $city;
  560.                 }
  561.             }
  562.             return $response;
  563.         }else{
  564.             return $workData['address']['city'];
  565.         }
  566.     }
  567.     public function resetSalaryData(string $categoryType): void{
  568.         $this->setSalaryData(null);
  569.     }
  570.     public function resetWorkData(string $categoryType): void{
  571.         $this->setWorkData(null);
  572.     }
  573.     public function setOfferNameFromItem(Item $item): void{
  574.         $this
  575.             ->setOfferNamePL($item->getName())
  576.             ->setOfferNameEN($item->getNameEn());
  577.     }
  578.     public function setOfferNameFromNull(): void{
  579.         $this
  580.             ->setOfferNamePL(null)
  581.             ->setOfferNameEN(null);
  582.     }
  583.     public function setOfferLevelFromNull(): void{
  584.         $this
  585.             ->setOfferLevelPL(null)
  586.             ->setOfferLevelEN(null);
  587.     }
  588.     public function setOfferLevelFromItem(Item $item): void{
  589.         $this
  590.             ->setOfferLevelPL($item->getName())
  591.             ->setOfferLevelEN($item->getNameEn());
  592.     }
  593.     /**
  594.      * @return DateTime|null
  595.      */
  596.     public function getPublishedAt(): ?DateTime
  597.     {
  598.         return $this->publishedAt;
  599.     }
  600.     /**
  601.      * @param DateTime|null $publishedAt
  602.      */
  603.     public function setPublishedAt(?DateTime $publishedAt): self
  604.     {
  605.         $this->publishedAt = $publishedAt;
  606.         return $this;
  607.     }
  608.     /**
  609.      * @return DateTime|null
  610.      */
  611.     public function getUpdateInsteps(): ?DateTime
  612.     {
  613.         return $this->updateInsteps;
  614.     }
  615.     /**
  616.      * @param DateTime|null $updateInsteps
  617.      */
  618.     public function setUpdateInsteps(?DateTime $updateInsteps): self
  619.     {
  620.         $this->updateInsteps = $updateInsteps;
  621.         return $this;
  622.     }
  623.     /**
  624.      * @return User|null
  625.      */
  626.     public function getUser(): ?User
  627.     {
  628.         return $this->user;
  629.     }
  630.     /**
  631.      * @param User|null $user
  632.      */
  633.     public function setUser(?User $user): self
  634.     {
  635.         $this->user = $user;
  636.         return $this;
  637.     }
  638.     /**
  639.      * @return string|null
  640.      */
  641.     public function getOfferLevelPL(): ?string
  642.     {
  643.         return $this->offerLevelPL;
  644.     }
  645.     /**
  646.      * @param string|null $offerLevelPL
  647.      */
  648.     public function setOfferLevelPL(?string $offerLevelPL): self
  649.     {
  650.         $this->offerLevelPL = $offerLevelPL;
  651.         return $this;
  652.     }
  653.     /**
  654.      * @return Collection|Application[]
  655.      */
  656.     public function getApplication(): Collection
  657.     {
  658.         return $this->application;
  659.     }
  660.     public function addApplication(Application $application): self
  661.     {
  662.         if (!$this->application->contains($application)) {
  663.             $this->application[] = $application;
  664.             $application->setOffer($this);
  665.         }
  666.         return $this;
  667.     }
  668.     /**
  669.      * @return string|null
  670.      */
  671.     public function getOfferLevelEN(): ?string
  672.     {
  673.         return $this->offerLevelEN;
  674.     }
  675.     /**
  676.      * @param string|null $offerLevelEN
  677.      */
  678.     public function setOfferLevelEN(?string $offerLevelEN): self
  679.     {
  680.         $this->offerLevelEN = $offerLevelEN;
  681.         return $this;
  682.     }
  683.     /**
  684.      * @return string|null
  685.      */
  686.     public function getAccessKey(): ?string
  687.     {
  688.         return $this->accessKey;
  689.     }
  690.     /**
  691.      * @param string|null $accessKey
  692.      */
  693.     public function setAccessKey(?string $accessKey): self
  694.     {
  695.         $this->accessKey = $accessKey;
  696.         return $this;
  697.     }
  698.     
  699.     public function removeApplication(Application $application): self
  700.     {
  701.         if ($this->application->removeElement($application)) {
  702.             // set the owning side to null (unless already changed)
  703.             if ($application->getOffer() === $this) {
  704.                 $application->setOffer(null);
  705.             }
  706.         }
  707.         return $this;
  708.     }
  709.      /**
  710.      * @return Collection|OfferLinkList[]
  711.      */
  712.     public function getOfferLinkList(): Collection
  713.     {
  714.         return $this->offerLinkList;
  715.     }
  716.     public function addOfferLinkList(OfferLinkList $offerLinkList): self
  717.     {
  718.         if (!$this->offerLinkList->contains($offerLinkList)) {
  719.             $this->offerLinkList[] = $offerLinkList;
  720.             $offerLinkList->setOffer($this);
  721.         }
  722.         return $this;
  723.     }
  724.     public function removeOfferLinkList(OfferLinkList $offerLinkList): self
  725.     {
  726.         if ($this->offerLinkList->removeElement($offerLinkList)) {
  727.             // set the owning side to null (unless already changed)
  728.             if ($offerLinkList->getOffer() === $this) {
  729.                 $offerLinkList->setOffer(null);
  730.             }
  731.         }
  732.         return $this;
  733.     }
  734.     public function getShortOfferCode(): ?string
  735.     {
  736.         return $this->shortOfferCode;
  737.     }
  738.     public function setShortOfferCode(?string $shortOfferCode): self
  739.     {
  740.         $this->shortOfferCode = $shortOfferCode;
  741.         return $this;
  742.     }
  743.     /**
  744.      * @return string|null
  745.      */
  746.     public function getChildCity(): ?string
  747.     {
  748.         return $this->childCity;
  749.     }
  750.     /**
  751.      * @param string|null $childCity
  752.      */
  753.     public function setChildCity(?string $childCity): self
  754.     {
  755.         $this->childCity = $childCity;
  756.         return $this;
  757.     }
  758.     /**
  759.      * @return array|null
  760.      */
  761.     public function getChildData(): ?array
  762.     {
  763.         return $this->childData;
  764.     }
  765.     /**
  766.      * @param array|null $childData
  767.      */
  768.     public function setChildData(?array $childData): self
  769.     {
  770.         $this->childData = $childData;
  771.         return $this;
  772.     }
  773.     public function getWorkDataStringByLocale(string $locale, TranslatorInterface $translator): string
  774.     {
  775.         $workDataString = '';
  776.         $workData = $this->getWorkData();
  777.         if(is_null($workData)) {
  778.             return $workDataString;
  779.         }
  780.         if (isset($workData['address'])) {
  781.             unset($workData['address']);
  782.         }
  783.         if(isset($workData['additional_data'])){
  784.             foreach ($workData['additional_data'] as $workDataExtra) {
  785.                 if(false === isset($workDataExtra['checked'])){ continue; }
  786.                 if ($workDataExtra['checked']) {
  787.                     $name = $workDataExtra[$locale] ?? null;
  788.                     if(is_null($name)) {
  789.                         continue;
  790.                     }
  791.                     $name = strtolower($name);
  792.                     $name = Slug::slug($name);
  793.                     $workDataString .= $name . '.';
  794.                 }
  795.             }
  796.             unset($workData['additional_data']);
  797.         }
  798.         foreach ($workData as $workDataKey => $workDataElement) {
  799.             if(false === isset($workDataElement['checked'])){ continue; }
  800.             if ($workDataElement['checked']) {
  801.                 $toTrans = $this->getTransTextFromWorkData($workDataKey);
  802.                 $name = $translator->trans($toTrans, [], null, $locale);
  803.                 $name = strtolower($name);
  804.                 $name = Slug::slug($name);
  805.                 $workDataString .= $name . '.';
  806.             }
  807.         }
  808.         return $workDataString;
  809.     }
  810.     public function getPackage(): ?Package
  811.     {
  812.         return $this->package;
  813.     }
  814.     public function setPackage(?Package $package): self
  815.     {
  816.         $this->package = $package;
  817.         return $this;
  818.     }
  819.     public function getOrder(): ?Orders
  820.     {
  821.         return $this->order;
  822.     }
  823.     public function setOrder(?Orders $order): self
  824.     {
  825.         $this->order = $order;
  826.         return $this;
  827.     }
  828.     public function getWorkDataPlString(TranslatorInterface $translator): string
  829.     {
  830.         return $this->getWorkDataStringByLocale('pl', $translator);
  831.     }
  832.     public function getWorkDataEnString(TranslatorInterface $translator): string
  833.     {
  834.         return $this->getWorkDataStringByLocale('en', $translator);
  835.     }
  836.     public function getSalaryStringByLocale(string $locale, TranslatorInterface $translator): string
  837.     {
  838.         $salaryString = '';
  839.         $salaryData = $this->getSalaryData();
  840.         if(is_null($salaryData)) {
  841.             return '';
  842.         }
  843.         foreach($salaryData as $salaryDataKey => $salaryDataElement){
  844.             $checked = $salaryDataElement['checked'] ?? false;
  845.             if(false === $checked) {
  846.                 continue;
  847.             }
  848.             $currency = $salaryDataElement['currency'] ?? null;
  849.             $salaryString .= $currency . '.';
  850.             $toTrans = $this->getTransTextFromSalary($salaryDataKey);
  851.             $name = $translator->trans($toTrans, [], null, $locale);
  852.             $name = strtolower($name);
  853.             $name = Slug::slug($name);
  854.             $salaryString .= $name . '.';
  855.         }
  856.         return $salaryString;
  857.     }
  858.     public function getSalaryPlString(TranslatorInterface $translator): string
  859.     {
  860.         return $this->getSalaryStringByLocale('pl', $translator);
  861.     }
  862.     public function getSalaryEnString(TranslatorInterface $translator): string
  863.     {
  864.         return $this->getSalaryStringByLocale('en', $translator);
  865.     }
  866.     private function getTransTextFromWorkData(string $workDataElement): string
  867.     {
  868.         return match ($workDataElement) {
  869.             'part_time' => 'USER_ZONE.OFFER.WORK_DATA.TYPES_LOW_CASE.TYPE_1',
  870.             'remote_work' => 'USER_ZONE.OFFER.WORK_DATA.TYPES_LOW_CASE.TYPE_2',
  871.             'flex_work_hour' => 'USER_ZONE.OFFER.WORK_DATA.TYPES_LOW_CASE.TYPE_3',
  872.             'shift_work' => 'USER_ZONE.OFFER.WORK_DATA.TYPES_LOW_CASE.TYPE_4',
  873.             'delegation' => 'USER_ZONE.OFFER.WORK_DATA.TYPES_LOW_CASE.TYPE_5',
  874.             'recruitment_remote' => 'USER_ZONE.OFFER.WORK_DATA.TYPES_LOW_CASE.TYPE_6',
  875.         };
  876.     }
  877.     private function getTransTextFromSalary(int $salaryElement): string{
  878.         return match ($salaryElement){
  879.             0 => 'USER_ZONE.HOME_PAGE.SELECT_CONTRACT_DROPDOWN_FILTER_2',
  880.             1 => 'USER_ZONE.HOME_PAGE.SELECT_CONTRACT_DROPDOWN_FILTER_5',
  881.             2 => 'USER_ZONE.HOME_PAGE.SELECT_CONTRACT_DROPDOWN_FILTER_4',
  882.             3 => 'USER_ZONE.HOME_PAGE.SELECT_CONTRACT_DROPDOWN_FILTER_3',
  883.             4 => 'USER_ZONE.HOME_PAGE.SELECT_CONTRACT_DROPDOWN_FILTER_6',
  884.         };
  885.     }
  886.     public function getSalarySlug(string $locale, TranslatorInterface $translator, string $searchKey): string
  887.     {
  888.         $toTrans = $this->getTransTextFromSalary($searchKey);
  889.         $name = $translator->trans($toTrans, [], null, $locale);
  890.         $name = strtolower($name);
  891.         return Slug::slug($name);
  892.     }
  893.     public function getWorkDataForAnotherPoint(): array
  894.     {
  895.         $worksDataArray = [];
  896.         $worksData = $this->getWorkData();
  897.         if(is_null($worksData)){ return $worksDataArray; }
  898.         if (isset($worksData['address'])) { unset($worksData['address']); }
  899.         if(isset($worksData['additional_data'])){
  900.             foreach ($worksData['additional_data'] as $workDataExtra) {
  901.                 if(false === isset($workDataExtra['checked'])){ continue; }
  902.                 if ($workDataExtra['checked']) {
  903.                     $plName = $workDataExtra['pl'] ?? null;
  904.                     $enName = $workDataExtra['en'] ?? null;
  905.                     $name = !is_null($plName) && !empty($plName) ? Slug::slug($plName) : Slug::slug($enName);
  906.                     $worksDataArray[] = $name;
  907.                 }
  908.             }
  909.             unset($worksData['additional_data']);
  910.         }
  911.         foreach ($worksData as $workDataKey => $workData) {
  912.             if(false === isset($workData['checked'])){ continue; }
  913.             if ($workData['checked']) {
  914.                 $newWorkDataKey = $this->replaceUnderscoreToHyphen($workDataKey);
  915.                 $worksDataArray[] = $newWorkDataKey;
  916.             }
  917.         }
  918.         return $worksDataArray;
  919.     }
  920.     public function getIndustryPLSlug(): ?string
  921.     {
  922.         $searchParams = $this->getIndustryFromSearchParams();
  923.         if(is_null($searchParams)){ return null; }
  924.         return $searchParams['pl']['name'] ?? null;
  925.     }
  926.     public function getIndustryENSlug(): ?string
  927.     {
  928.         $searchParams = $this->getIndustryFromSearchParams();
  929.         if(is_null($searchParams)){ return null; }
  930.         return $searchParams['en']['name'] ?? null;
  931.     }
  932.     public function getPointFromLevenshtein(array $search, string $industryPL, string $industryEN, int $levenshteinDivider): float
  933.     {
  934.         $points = 0.0;
  935.         foreach($search as $searchElement){
  936.             $industryPLPoint     = levenshtein($searchElement, $industryPL);
  937.             $industryENPoint     = levenshtein($searchElement, $industryEN);
  938.             $itemPoints          = $this->getHighestValueFromTwo($industryPLPoint, $industryENPoint);
  939.             $points             += (1/$itemPoints) * 100;
  940.         }
  941.         return $points/$levenshteinDivider;
  942.     }
  943.     private function getIndustryFromSearchParams(): ?array{
  944.         $industry = null;
  945.         $searchParams = $this->getSearchParams();
  946.         if(isset($searchParams['industry'])){ $industry = $searchParams['industry']; }
  947.         if(is_null($industry)){ return null; }
  948.         return $industry;
  949.     }
  950.     public function getItemsForTechnologyPoint(): array
  951.     {
  952.         $itemsFromOffer = [];
  953.         $offerItems = $this->getOfferItems()->toArray();
  954.         foreach($offerItems as $offerItem){
  955.             $itemsFromOfferItems = $offerItem->getItems()->toArray();
  956.             foreach($itemsFromOfferItems as $item){
  957.                 $itemsFromOffer[] = $item;
  958.             }
  959.         }
  960.         return $itemsFromOffer;
  961.     }
  962.     public function getLocationForLocationPoint(): string
  963.     {
  964.         $city = $this->getCityNameFromWorkData();
  965.         return Slug::slug($city);
  966.     }
  967.     public function getOfferNamePLSlug(): string
  968.     {
  969.         return Slug::slug($this->getOfferNamePL());
  970.     }
  971.     public function getOfferNameENSlug(): string
  972.     {
  973.         return Slug::slug($this->getOfferNameEN());
  974.     }
  975.     public function getSalaryForSalaryPoint(int $hourInMonth): array
  976.     {
  977.         $salary = [];
  978.         $salaryData = $this->getSalaryData();
  979.         if(is_null($salaryData)){ return []; }
  980.         foreach($salaryData as $salaryDataKey => $salaryDataElement){
  981.             $checked = $salaryDataElement['checked'] ?? false;
  982.             if(false === $checked){ continue; }
  983.             $period = $salaryDataElement['period'] ?? null;
  984.             $from = $salaryDataElement['from'] ?? null;
  985.             $to = $salaryDataElement['to'] ?? null;
  986.             $currency = $salaryDataElement['currency'] ?? null;
  987.             $type = $this->getType($salaryDataKey);
  988.            
  989.             $fromWithPeriod = $this->getFromForSalaryTypePoint($period, $from, $hourInMonth);
  990.             $toWithPeriod = $this->getToForSalaryTypePoint($period, $to, $hourInMonth);
  991.             $salary[] = ['currency' => $currency, 'type' => $type, 'from' => $fromWithPeriod, 'to' => $toWithPeriod];
  992.         }
  993.         return $salary;
  994.     }
  995.     public function getSearchParamsForSearchPoint(): array
  996.     {
  997.         $data = [];
  998.         $searchParams = $this->getSearchParams();
  999.         foreach($searchParams as $searchParamsKey => $searchParamsElement){
  1000.             if(is_array($searchParamsElement)){
  1001.                 if($searchParamsKey === 'items'){
  1002.                     $en = $searchParamsElement['en'] ?? '';
  1003.                     $pl = $searchParamsElement['pl'] ?? '';
  1004.                     $itemsDataEn = explode('.', $en);
  1005.                     $itemsDataPl = explode('.', $pl);
  1006.                     foreach ($itemsDataEn as $itemEn){
  1007.                         if($itemEn !== '') {
  1008.                             $itemEn = str_replace('-', ' ', $itemEn);
  1009.                             $data[] = strtolower($itemEn);
  1010.                         }
  1011.                     }
  1012.                     foreach ($itemsDataPl as $itemPl){
  1013.                         if($itemPl !== ''){
  1014.                             $itemPl = str_replace('-', ' ', $itemPl);
  1015.                             $data[] = strtolower($itemPl);
  1016.                         }
  1017.                     }
  1018.                 }
  1019.                 if($searchParamsKey === 'company'){
  1020.                     $companyName = $searchParamsElement['name'] ?? null;
  1021.                     if(false === is_null($companyName)){
  1022.                         $companyName = str_replace(['Ą', 'Ć', 'Ę', 'Ł', 'Ń', 'Ó', 'Ś', 'Ź', 'Ż'], ['ą', 'ć', 'ę', 'ł', 'ń', 'ó', 'ś', 'ź', 'ż'], $companyName);
  1023.                         $data[] = strtolower($companyName);
  1024.                     }
  1025.                 }
  1026.                 if($searchParamsKey === 'industry'){
  1027.                     $industryEn = $searchParamsElement['en']['name'] ?? null;
  1028.                     $industryPl = $searchParamsElement['pl']['name'] ?? null;
  1029.                     if(false === is_null($industryEn)){
  1030.                         $industryEn = str_replace('-', ' ', $industryEn);
  1031.                         $data[] = strtolower($industryEn);
  1032.                     }
  1033.                     if(false === is_null($industryPl)){
  1034.                         $industryPl = str_replace('-', ' ', $industryPl);
  1035.                         $data[] = strtolower($industryPl);
  1036.                     }
  1037.                 }
  1038.                 if($searchParamsKey === 'workData') {
  1039.                     $en = $searchParamsElement['en'] ?? '';
  1040.                     $pl = $searchParamsElement['pl'] ?? '';
  1041.                     $itemsDataEn = explode('.', $en);
  1042.                     $itemsDataPl = explode('.', $pl);
  1043.                     foreach ($itemsDataEn as $itemEn){
  1044.                         if($itemEn !== '') {
  1045.                             $itemEn = str_replace('-', ' ', $itemEn);
  1046.                             $data[] = strtolower($itemEn);
  1047.                         }
  1048.                     }
  1049.                     foreach ($itemsDataPl as $itemPl){
  1050.                         if($itemPl !== ''){
  1051.                             $itemPl = str_replace('-', ' ', $itemPl);
  1052.                             $data[] = strtolower($itemPl);
  1053.                         }
  1054.                     }
  1055.                 }
  1056.                 if($searchParamsKey === 'salary') {
  1057.                     $en = $searchParamsElement['en'] ?? '';
  1058.                     $pl = $searchParamsElement['pl'] ?? '';
  1059.                     $itemsDataEn = explode('.', $en);
  1060.                     $itemsDataPl = explode('.', $pl);
  1061.                     foreach ($itemsDataEn as $itemEn){
  1062.                         if($itemEn !== '') {
  1063.                             $itemEn = str_replace('-', ' ', $itemEn);
  1064.                             $data[] = strtolower($itemEn);
  1065.                         }
  1066.                     }
  1067.                     foreach ($itemsDataPl as $itemPl){
  1068.                         if($itemPl !== ''){
  1069.                             $itemPl = str_replace('-', ' ', $itemPl);
  1070.                             $data[] = strtolower($itemPl);
  1071.                         }
  1072.                     }
  1073.                 }
  1074.                 continue;
  1075.             }
  1076.             $data[] = strtolower($searchParamsElement);
  1077.         }
  1078.         $data = array_unique($data);
  1079.         return $data;
  1080.     }
  1081.     private function getType(int $type): string{
  1082.         return match ($type){
  1083.             0 => 'umowa_o_prace',
  1084.             1 => 'b2b',
  1085.             2 => 'umowa_zlecenie',
  1086.             3 => 'umowa_o_dzielo',
  1087.             4 => 'staz_praktyka',
  1088.         };
  1089.     }
  1090.     private function getFromForSalaryTypePoint(?string $period, ?string $from, int $hourInMonth): float{
  1091.         $correctPeriod = $this->getCorrectPeriod($period, $hourInMonth);
  1092.         return ($correctPeriod * intval($from));
  1093.     }
  1094.     private function getToForSalaryTypePoint(?string $period, ?string $to, int $hourInMonth): float{
  1095.         $correctPeriod = $this->getCorrectPeriod($period, $hourInMonth);
  1096.         return ($correctPeriod * intval($to));
  1097.     }
  1098.     private function getCorrectPeriod(?string $period, int $hourInMonth): float{
  1099.         $period = intval($period);
  1100.         return match ($period) {
  1101.             0 => 1,
  1102.             1 => $hourInMonth,
  1103.             2 => (1 / 12),
  1104.             default => 1
  1105.         };
  1106.     }
  1107.     private function replaceUnderscoreToHyphen(string $word): string
  1108.     {
  1109.         $word = strtolower($word);
  1110.         return str_replace('_', '-', $word);
  1111.     }
  1112.     private function getHighestValueFromTwo(?int $first, ?int $second): int{
  1113.         if(is_null($first)) { $first = 0; }
  1114.         if(is_null($second)){ $second = 0; }
  1115.         return max($first, $second);
  1116.     }
  1117.     /**
  1118.      * @return Collection<int, SharedOffer>
  1119.      */
  1120.     public function getSharedOffers(): Collection
  1121.     {
  1122.         return $this->sharedOffers;
  1123.     }
  1124.     public function addSharedOffer(SharedOffer $sharedOffer): self
  1125.     {
  1126.         if (!$this->sharedOffers->contains($sharedOffer)) {
  1127.             $this->sharedOffers[] = $sharedOffer;
  1128.             $sharedOffer->setOfferId($this);
  1129.         }
  1130.         return $this;
  1131.     }
  1132.     public function removeSharedOffer(SharedOffer $sharedOffer): self
  1133.     {
  1134.         if ($this->sharedOffers->removeElement($sharedOffer)) {
  1135.             // set the owning side to null (unless already changed)
  1136.             if ($sharedOffer->getOfferId() === $this) {
  1137.                 $sharedOffer->setOfferId(null);
  1138.             }
  1139.         }
  1140.         return $this;
  1141.     }
  1142.     public function getCreator(): ?string
  1143.     {
  1144.         return $this->creator;
  1145.     }
  1146.     public function setCreator(?string $creator): self
  1147.     {
  1148.         $this->creator = $creator;
  1149.         return $this;
  1150.     }
  1151.     public function getLanguage(): ?string
  1152.     {
  1153.         return $this->language;
  1154.     }
  1155.     public function setLanguage(?string $language): self
  1156.     {
  1157.         $this->language = $language;
  1158.         return $this;
  1159.     }
  1160.     public function getNumberOfInsteps()
  1161.     {
  1162.         return $this->numberOfInsteps;
  1163.     }
  1164.     public function setNumberOfInsteps($numberOfInsteps): self
  1165.     {
  1166.         $this->numberOfInsteps = $numberOfInsteps;
  1167.         return $this;
  1168.     }
  1169.     public function getChildLocations(): array
  1170.     {
  1171.         $response = [];
  1172.         foreach ($this->getOffers() as $childOffer){
  1173.             if(is_null($childOffer->getWorkData()['address']['city'] ?? null) === false) {
  1174.                 if (is_array($childOffer->getWorkData()['address']['city']) === false) {
  1175.                     $response[] = $childOffer->getWorkData()['address']['city'] ?? '';
  1176.                 }
  1177.             }
  1178.         }
  1179.         return array_unique($response);
  1180.     }
  1181.     public function isMainOffer(): bool
  1182.     {
  1183.         return false === $this->getOffers()->isEmpty();
  1184.     }
  1185.     public function createManyChildOffer(EntityManagerInterface $entityManager, Offer $cloneOffer = null): array
  1186.     {
  1187.         $cities = $this->getWorkData()['address']['city'] ?? [];
  1188.         $offerCreateLength = count($cities);
  1189.         $childOffers = [];
  1190.         if ($offerCreateLength > 1) {
  1191.             foreach ($cities as $key => $city) {
  1192.                 $childOffer = $this->cloneChild(
  1193.                     null,
  1194.                     $key,
  1195.                     $cloneOffer
  1196.                 );
  1197.                 $childOffers[] = $childOffer;
  1198.                 if (is_null($cloneOffer)) {
  1199.                     $this->addOffers($childOffer);
  1200.                 } else {
  1201.                     $cloneOffer->addOffers($childOffer);
  1202.                 }
  1203.                 $entityManager->persist($childOffer);
  1204.                 $entityManager->persist($this);
  1205.                 $entityManager->flush();
  1206.             }
  1207.         }
  1208.         return $childOffers;
  1209.     }
  1210.     public function createLocationAndGetOffer(): array
  1211.     {
  1212.         $response = [];
  1213.         $workData = $this->getWorkData();
  1214.         if(is_null($workData)){ return []; }
  1215.         if(false === isset($workData['address'])){ return []; }
  1216.         if(false === isset($workData['address']['city'])){ return []; };
  1217.         if(is_array($workData['address']['city'])){
  1218.             $lastKey = count($workData['address']['city']);
  1219.             foreach ($workData['address']['city'] as $key =>  $city){
  1220.                 if($lastKey !== $key + 1){
  1221.                     $response[] = [
  1222.                         'name'=> $city.', ',
  1223.                         'offer' => $this->getOfferByCityName($city),
  1224.                     ];
  1225.                 }else{
  1226.                     $response[] = [
  1227.                         'name'=> $city,
  1228.                         'offer' => $this->getOfferByCityName($city),
  1229.                     ];
  1230.                 }
  1231.             }
  1232.             return $response;
  1233.         }else{
  1234.             $city = $workData['address']['city'];
  1235.             $response[] = [
  1236.                 'name'=> $city,
  1237.                 'offer' => $this->getOfferByCityName($city),
  1238.             ];
  1239.             return $response;
  1240.         }
  1241.     }
  1242.     public function getOfferByCityName(string $cityName): ?Offer
  1243.     {
  1244.         foreach ($this->getOffers() ?? [] as $childOffer){
  1245.             if(is_array($childOffer->getWorkData()['address']['city'] ?? []) === false){
  1246.                 if($childOffer->getWorkData()['address']['city'] === $cityName){
  1247.                     return $childOffer;
  1248.                 }
  1249.             }
  1250.         }
  1251.         return null;
  1252.     }
  1253.     public function createChildOffer(EntityManagerInterface $entityManager , int $key): Offer
  1254.     {
  1255.         $childOffer = $this->cloneChild(
  1256.             null,
  1257.             $key,
  1258.             $this
  1259.         );
  1260.         $this->addOffers($childOffer);
  1261.         $entityManager->persist($childOffer);
  1262.         $entityManager->persist($this);
  1263.         $entityManager->flush();
  1264.         return $childOffer;
  1265.     }
  1266.     private function createSearchParamsWithKey(?array &$offerWorkData, array &$searchParams, int $key): void
  1267.     {
  1268.         if(is_null($offerWorkData)){
  1269.             return;
  1270.         }
  1271.         if(is_array($offerWorkData['address']['city'])){
  1272.             $searchParams['city'] = Slug::slug($offerWorkData['address']['city'][$key] ?? '');
  1273.         }else{
  1274.             $searchParams['city'] = Slug::slug($offerWorkData['address']['city'] ?? '');
  1275.         }
  1276.         if(is_array($offerWorkData['address']['country'])){
  1277.             $searchParams['country'] = Slug::slug($offerWorkData['address']['country'][$key] ?? '');
  1278.         }else{
  1279.             $searchParams['country'] = Slug::slug($offerWorkData['address']['country'] ?? '');
  1280.         }
  1281.     }
  1282.     private function createWorkDataWithKey(?array &$offerWorkData, int $key): void
  1283.     {
  1284.         if(is_null($offerWorkData)){
  1285.             return;
  1286.         }
  1287.         if(is_array($offerWorkData['address']['country'])){
  1288.             $offerWorkData['address']['country'] = $offerWorkData['address']['country'][$key] ?? '';
  1289.         }
  1290.         if(is_array($offerWorkData['address']['pl_name'])){
  1291.             $offerWorkData['address']['pl_name'] = $offerWorkData['address']['pl_name'][$key] ?? '';
  1292.         }
  1293.         if(is_array($offerWorkData['address']['city'])){
  1294.             $offerWorkData['address']['city'] = $offerWorkData['address']['city'][$key] ?? '';
  1295.         }
  1296.         if(is_array($offerWorkData['address']['street'])){
  1297.             $offerWorkData['address']['street'] = $offerWorkData['address']['street'][$key] ?? '';
  1298.         }
  1299.         if(is_array($offerWorkData['address']['lat'])){
  1300.             $offerWorkData['address']['lat'] = $offerWorkData['address']['lat'][$key] ?? '';
  1301.         }
  1302.         if(is_array($offerWorkData['address']['lnt'])){
  1303.             $offerWorkData['address']['lnt'] = $offerWorkData['address']['lnt'][$key] ?? '';
  1304.         }
  1305.     }
  1306.     public function editUserChildOffer(Offer $offer, ?User $user): void
  1307.     {
  1308.         if($offer->getOffers()){
  1309.             foreach ($offer->getOffers() as $childOffer){
  1310.                 $childOffer->setUser($user);
  1311.             }
  1312.         }
  1313.     }
  1314.     public function editOrderChildOffer(Offer $offer, ?Orders $order): void
  1315.     {
  1316.         if($offer->getOffers()){
  1317.             foreach ($offer->getOffers() as $childOffer){
  1318.                 $childOffer->setOrder($order);
  1319.             }
  1320.         }
  1321.     }
  1322.     public function getStatusColor(): string
  1323.     {
  1324.         if ($this->getActive()) {
  1325.             return self::STATUS_GREEN;
  1326.         }
  1327.         return self::STATUS_RED;
  1328.     }
  1329.     public function updateOfferChildActiveAndDone(): void
  1330.     {
  1331.         if ($this->getOffers()) {
  1332.             foreach ($this->getOffers() as $childOffer) {
  1333.                 $childOffer->setActive($this->getActive());
  1334.                 $childOffer->setDone($this->getDone());
  1335.             }
  1336.         }
  1337.     }
  1338.     public function setKeywordsChildOffer(): void
  1339.     {
  1340.             if ($this->getOffers()) {
  1341.                 foreach ($this->getOffers() as $childOffer) {
  1342.                     $childOffer->generateKeywords();
  1343.                 }
  1344.             }
  1345.     }
  1346.     public function generateKeywords(): void
  1347.     {
  1348.         $keywords = '';
  1349.         $searchParams = $this->getSearchParams();
  1350.         if (empty($searchParams) || !isset($searchParams['items'])) {
  1351.             return;
  1352.         }
  1353.         $anotherKeywords= '';
  1354.         foreach ($searchParams['another'] ?? [] as $another) {
  1355.             $anotherKeywords .= $another.'.';
  1356.         }
  1357.         $cityKeywords = $searchParams['city'];
  1358.         if (is_array($cityKeywords)) {
  1359.             $cityKeywords = '';
  1360.             foreach ($searchParams['city'] as $city) {
  1361.                 $cityKeywords .= $city.'.';
  1362.             }
  1363.         } else {
  1364.             $cityKeywords .= '.';
  1365.         }
  1366.         $countryKeywords = $searchParams['country'];
  1367.         if (is_array($countryKeywords)) {
  1368.             $countryKeywords = '';
  1369.             foreach ($searchParams['country'] as $country) {
  1370.                 $countryKeywords .= $country.'.';
  1371.             }
  1372.         } else {
  1373.             $countryKeywords .= '.';
  1374.         }
  1375.         $keywords .= $cityKeywords;
  1376.         $keywords .= $anotherKeywords;
  1377.         $keywords .= $countryKeywords;
  1378.         $keywords .= $searchParams['industry']['en']['name'].'.';
  1379.         $keywords .= ($searchParams['industry']['pl']['name'] ?? '').'.';
  1380.         $keywords .= ($searchParams['workData']['en'] ?? '').'.';
  1381.         $keywords .= ($searchParams['workData']['pl'] ?? '').'.';
  1382.         $keywords .= ($searchParams['company']['slug'] ?? '').'.';
  1383.         $keywords .= ($searchParams['salary']['en'] ?? '').'.';
  1384.         $keywords .= ($searchParams['salary']['pl'] ?? '').'.';
  1385.         $keywords .= ($searchParams['items']['en'] ?? '').'.';
  1386.         $keywords .= ($searchParams['items']['pl'] ?? '');
  1387.         $this->keywords = $keywords;
  1388.     }
  1389.     public function isVisible(): bool
  1390.     {
  1391.         return $this->visible;
  1392.     }
  1393.     public function setVisible(bool $visible): self
  1394.     {
  1395.         $this->visible = $visible;
  1396.         return $this;
  1397.     }
  1398. }