src/Entity/Company.php line 1314

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Billing;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use App\Utils\File\FileServiceTrait;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Symfony\Component\HttpFoundation\File\UploadedFile;
  11. /**
  12.  * @ORM\Entity(repositoryClass="App\Repository\CompanyRepository")
  13.  * @Vich\Uploadable
  14.  */
  15. class Company implements \JsonSerializable
  16. {
  17.     use FileServiceTrait;
  18.     
  19.     public  $targetDirectory;
  20.     const FILE_LOGO = "logo";
  21.     const FILE_COVER = "cover";
  22.     const FILE_PDF = "pdf";
  23.     const FILES = [
  24.         self::FILE_LOGO => [
  25.             'types' => ['gif', 'jpg', 'jpeg', 'png', 'tif', 'svg'],
  26.             'dir' => '/company_logo',
  27.             'size' => 5*1024*1024,
  28.         ],
  29.         self::FILE_COVER => [
  30.             'types' => ['gif', 'jpg', 'jpeg', 'png', 'tif', 'svg'],
  31.             'dir' => '/company_cover',
  32.             'size' => 5*1024*1024,
  33.         ],
  34.         self::FILE_PDF => [
  35.             'types' => ['pdf'],
  36.             'dir' => '/company_pdf',
  37.             'size' => 5*1024*1024,
  38.         ]
  39.     ];
  40.     const STATUS_ACTIVE = 1;
  41.     const STATUS_INACTIVE = 2;
  42.     const STATUSES = [
  43.         self::STATUS_ACTIVE => "Active",
  44.         self::STATUS_INACTIVE => "Inactive"
  45.     ];
  46.     const COMPANY_FOLLOWERS_CHOOSE = 0;
  47.     const COMPANY_FOLLOWERS_MIN = 1;
  48.     const COMPANY_FOLLOWERS_MAX = 2;
  49.     const COMPANY_FOLLOWERS = [
  50.         self::COMPANY_FOLLOWERS_CHOOSE => "Choose",
  51.         self::COMPANY_FOLLOWERS_MIN => "Min",
  52.         self::COMPANY_FOLLOWERS_MAX => "Max",
  53.     ];
  54.     
  55.     /**
  56.      * @ORM\Id()
  57.      * @ORM\GeneratedValue()
  58.      * @ORM\Column(type="integer")
  59.      */
  60.     private $id;
  61.     
  62.     /**
  63.      * One Company has One User.
  64.      * @ORM\OneToOne(targetEntity="User", inversedBy="company")
  65.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
  66.      */
  67.     private $user;
  68.     /**
  69.      * @ORM\Column(type="string", length=128)
  70.      */
  71.     private $companyName;
  72.     /**
  73.      * @ORM\ManyToMany(targetEntity="App\Entity\Industry")
  74.      */
  75.     private $industry;
  76.     
  77.      /**
  78.      * @ORM\ManyToOne(targetEntity="App\Entity\City")
  79.      * @ORM\JoinColumn(nullable=true)
  80.      */
  81.     private $city;
  82.     /**
  83.      * @ORM\Column(type="string", length=255, nullable=true)
  84.      */
  85.     private $address;
  86.     /**
  87.      * @ORM\Column(type="integer", nullable=true)
  88.      */
  89.     private $companySize;
  90.     /**
  91.      * @ORM\Column(type="integer", nullable=true)
  92.      */
  93.     private $employeesAverageSize;
  94.     /**
  95.      * @ORM\Column(type="string", length=255, nullable=true)
  96.      */
  97.     private $website;
  98.     
  99.     /**
  100.      * @ORM\Column(type="string", length=255, nullable=true)
  101.      */
  102.     private $email;
  103.     
  104.     /**
  105.      * @ORM\Column(type="string", length=255, nullable=true)
  106.      */
  107.     private $facebook;
  108.     
  109.     /**
  110.      * @ORM\Column(type="string", length=255, nullable=true)
  111.      */
  112.     private $twitter;
  113.     
  114.     /**
  115.      * @ORM\Column(type="string", length=255, nullable=true)
  116.      */
  117.     private $linkedin;
  118.     
  119.     /**
  120.      * @ORM\Column(type="string", length=255, nullable=true)
  121.      */
  122.     private $instagram;
  123.     /**
  124.      * @Assert\Length(max="14")
  125.      * @ORM\Column(type="string", length=14, nullable=true)
  126.      */
  127.     private $phone;
  128.     /**
  129.      * @ORM\Column(type="string", length=255, nullable=true)
  130.      */
  131.     private $subdomain;
  132.     /**
  133.      * @ORM\Column(type="text")
  134.      */
  135.     private $description;
  136.     /**
  137.      * @ORM\Column(type="text",  nullable=true)
  138.      */
  139.     private $faq;
  140.     
  141.     /**
  142.      * @ORM\Column(type="text",  nullable=true)
  143.      */
  144.     private $gdpr;
  145.     /**
  146.      * @ORM\Column(type="boolean", options={"default":"0"})
  147.      */
  148.     private $featured = FALSE;
  149.     /**
  150.      * @ORM\Column(type="boolean", options={"default":"0"})
  151.      */
  152.     private $addon = FALSE;
  153.     /**
  154.      * @ORM\Column(type="boolean", options={"default":"0"})
  155.      */
  156.     private $newsOption = FALSE;
  157.     /**
  158.      * @ORM\OneToOne(targetEntity="App\Entity\Billing", mappedBy="company", cascade={"persist"}))
  159.      */
  160.     private $billing;
  161.     /**
  162.      * @ORM\OneToMany(targetEntity="App\Entity\JobPosition", mappedBy="company")
  163.      */
  164.     private $jobPositions;
  165.     /**
  166.      * @ORM\OneToMany(targetEntity="App\Entity\News", mappedBy="company")
  167.      */
  168.     private $news;
  169.     /**
  170.      * @ORM\OneToMany(targetEntity="App\Entity\CompanySubscription", mappedBy="company")
  171.      */
  172.     private $subscriptions;
  173.     /**
  174.      * @ORM\ManyToMany(targetEntity="App\Entity\Candidate", inversedBy="followedCompanies")
  175.      */
  176.     private $followers;
  177.     
  178.     /**
  179.      * @ORM\OneToMany(targetEntity="App\Entity\CompanyCompanyAdvantage", mappedBy="company")
  180.      */
  181.     private $advantages;
  182.     /**
  183.      * @ORM\OneToMany(targetEntity="App\Entity\CompanyAboutUs", mappedBy="company")
  184.      */
  185.     private $aboutUs;
  186.     /**
  187.      * @ORM\OneToMany(targetEntity="App\Entity\CompanyMosaic", mappedBy="company")
  188.      */
  189.     private $mosaic;
  190.     /**
  191.      * @ORM\OneToMany(targetEntity="App\Entity\CompanyGallery", mappedBy="company")
  192.      */
  193.     private $gallery;
  194.     /**
  195.      * @ORM\Column(type="integer", options={"default": "1"})
  196.     */
  197.     private $status;
  198.     /**
  199.      * @ORM\Column(type="boolean", options={"default":"0"})
  200.      */
  201.     private $mkariera = FALSE;
  202.     /**
  203.      * @ORM\Column(type="string", length=255, nullable=true)
  204.      */
  205.     private $publication;
  206.     /**
  207.      * @ORM\Column(type="string", length=255, nullable=true)
  208.      * @var string|null
  209.      */
  210.     private $coverThumbnail;
  211.      /**
  212.      * @Vich\UploadableField(mapping="thumbnails", fileNameProperty="coverThumbnail")
  213.      * @var File|null
  214.      */
  215.     private $coverImageFile;
  216.      /**
  217.      * @ORM\Column(type="string", length=255, nullable=true)
  218.      * @var string|null
  219.      */
  220.     private $logoThumbnail;
  221.      /**
  222.      * @Vich\UploadableField(mapping="thumbnails", fileNameProperty="logoThumbnail")
  223.      * @var File|null
  224.      */
  225.     private $logoImageFile;
  226.      /**
  227.      * @ORM\Column(type="string", length=255, nullable=true)
  228.      * @var string|null
  229.      */
  230.     private $pdfPreview;
  231.      /**
  232.      * @Vich\UploadableField(mapping="thumbnails", fileNameProperty="pdfPreview")
  233.      * @var File|null
  234.      */
  235.     private $pdfFile;
  236.     /**
  237.      * @ORM\Column(type="datetime", nullable=true)
  238.      */
  239.     private $imageUpdatedAt;
  240.     
  241.     public function __construct()
  242.     {
  243.         $this->setStatus(self::STATUS_ACTIVE);
  244.         $this->industry = new ArrayCollection();
  245.         $this->jobPositions = new ArrayCollection();
  246.         $this->subscriptions = new ArrayCollection();
  247.         $this->followers = new ArrayCollection();
  248.         $this->advantages = new ArrayCollection();
  249.         $this->aboutUs = new ArrayCollection();
  250.         $this->mosaic = new ArrayCollection();
  251.         $this->gallery = new ArrayCollection();
  252.         $this->billing = new Billing();
  253.     }
  254.     public function getId(): ?int
  255.     {
  256.         return $this->id;
  257.     }
  258.     public function getUser(): ?User
  259.     {
  260.         return $this->user;
  261.     }
  262.     public function setUser(User $user): self
  263.     {
  264.         $this->user = $user;
  265.         return $this;
  266.     }
  267.     /**
  268.      * @param User $user
  269.      *
  270.      * @return Candidate
  271.      */
  272.     public function removeUser(User $user): Company {
  273.         if ($this->user == $user) {
  274.             $this->user = null;
  275.         }
  276.         return $this;
  277.     }
  278.     public function getCompanyName(): ?string
  279.     {
  280.         return $this->companyName;
  281.     }
  282.     public function setCompanyName(string $companyName): self
  283.     {
  284.         $this->companyName = $companyName;
  285.         return $this;
  286.     }
  287.     /**
  288.      * @return Collection|Industry[]
  289.      */
  290.     public function getIndustry(): Collection
  291.     {
  292.         return $this->industry;
  293.     }
  294.     
  295.     public function addIndustry(Industry $industry): self
  296.     {
  297.         if (!$this->industry->contains($industry)) {
  298.             $this->industry[] = $industry;
  299.         }
  300.         
  301.         return $this;
  302.     }
  303.     public function removeIndustry(Industry $industry): self
  304.     {
  305.         if ($this->industry->contains($industry)) {
  306.             $this->industry->removeElement($industry);
  307.         }
  308.         return $this;
  309.     }
  310.     
  311.     public function removeIndustryAll(){
  312.         $this->industry->clear();
  313.     }
  314.     
  315.     public function getCity(): ?City
  316.     {
  317.         return $this->city;
  318.     }
  319.     public function setCity(City $city): self
  320.     {
  321.         $this->city = $city;
  322.         return $this;
  323.     }
  324.     public function getAddress(): ?string
  325.     {
  326.         return $this->address;
  327.     }
  328.     public function setAddress(?string $address): self
  329.     {
  330.         $this->address = $address;
  331.         return $this;
  332.     }
  333.     public function getCompanySize(): ?string
  334.     {
  335.         return $this->companySize;
  336.     }
  337.     public function setCompanySize(?string $companySize): self
  338.     {
  339.         $this->companySize = $companySize;
  340.         return $this;
  341.     }
  342.     public function getEmployeesAverageSize(): ?string
  343.     {
  344.         return $this->employeesAverageSize;
  345.     }
  346.     public function setEmployeesAverageSize(?string $employeesAverageSize): self
  347.     {
  348.         $this->employeesAverageSize = $employeesAverageSize;
  349.         return $this;
  350.     }
  351.     public function getWebsite(): ?string
  352.     {
  353.         return $this->website;
  354.     }
  355.     public function setWebsite(?string $website): self
  356.     {
  357.         $this->website = $website;
  358.         return $this;
  359.     }
  360.     
  361.     public function getEmail(): ?string
  362.     {
  363.         return $this->email;
  364.     }
  365.     public function setEmail(string $email): self
  366.     {
  367.         $this->email = $email;
  368.         return $this;
  369.     }
  370.     public function getFacebook(): ?string
  371.     {
  372.         return $this->facebook;
  373.     }
  374.     public function setFacebook(?string $facebook): self
  375.     {
  376.         $this->facebook = $facebook;
  377.         return $this;
  378.     }
  379.     public function getTwitter(): ?string
  380.     {
  381.         return $this->twitter;
  382.     }
  383.     public function setTwitter(?string $twitter): self
  384.     {
  385.         $this->twitter = $twitter;
  386.         return $this;
  387.     }
  388.     public function getLinkedin(): ?string
  389.     {
  390.         return $this->linkedin;
  391.     }
  392.     public function setLinkedin(?string $linkedin): self
  393.     {
  394.         $this->linkedin = $linkedin;
  395.         return $this;
  396.     }
  397.     public function getInstagram(): ?string
  398.     {
  399.         return $this->instagram;
  400.     }
  401.     public function setInstagram(?string $instagram): self
  402.     {
  403.         $this->instagram = $instagram;
  404.         return $this;
  405.     }
  406.     public function getPhone(): ?string
  407.     {
  408.         return $this->phone;
  409.     }
  410.     public function setPhone(?string $phone): self
  411.     {
  412.         $this->phone = $phone;
  413.         return $this;
  414.     }
  415.     public function getSubdomain(): ?string
  416.     {
  417.         return $this->subdomain;
  418.     }
  419.     public function setSubdomain(?string $subdomain): self
  420.     {
  421.         $this->subdomain = $subdomain;
  422.         return $this;
  423.     }
  424.     public function getDescription(): ?string
  425.     {
  426.         return $this->description;
  427.     }
  428.     public function setDescription(string $description): self
  429.     {
  430.         $this->description = $description;
  431.         return $this;
  432.     }
  433.     public function getFaq(): ?string
  434.     {
  435.         return $this->faq;
  436.     }
  437.     public function setFaq(?string $faq): self
  438.     {
  439.         $this->faq = $faq;
  440.         return $this;
  441.     }
  442.     
  443.     public function getGdpr(): ?string
  444.     {
  445.         return $this->gdpr;
  446.     }
  447.     public function setGdpr(?string $gdpr): self
  448.     {
  449.         $this->gdpr = $gdpr;
  450.         return $this;
  451.     }
  452.     /**
  453.      * @return bool
  454.      */
  455.     public function getFeatured(): bool {
  456.         return $this->featured;
  457.     }
  458.     /**
  459.      * @param bool $featured
  460.      *
  461.      * @return self
  462.      */
  463.     public function setFeatured(bool $featured): self {
  464.         $this->featured = $featured;
  465.         return $this;
  466.     }
  467.     /**
  468.      * @return bool
  469.      */
  470.     public function getAddon(): bool {
  471.         return $this->addon;
  472.     }
  473.     /**
  474.      * @param bool $addon
  475.      *
  476.      * @return self
  477.      */
  478.     public function setAddon(bool $addon): self {
  479.         $this->addon = $addon;
  480.         return $this;
  481.     }
  482.     /**
  483.      * @return bool
  484.      */
  485.     public function getNewsOption(): bool {
  486.         return $this->newsOption;
  487.     }
  488.     /**
  489.      * @param bool $newsOption
  490.      *
  491.      * @return self
  492.      */
  493.     public function setNewsOption(bool $newsOption): self {
  494.         $this->newsOption = $newsOption;
  495.         return $this;
  496.     }
  497.     
  498.     public function getBilling(): ?Billing
  499.     {
  500.         return $this->billing;
  501.     }
  502.     public function setBilling(?Billing $billing): self
  503.     {
  504.         $this->billing = $billing;
  505.         return $this;
  506.     }
  507.     
  508.     /**
  509.      * @return Collection|JobPosition[]
  510.      */
  511.     public function getJobPositions() {
  512.         return $this->jobPositions;
  513.     }
  514.     /**
  515.      * @return Collection|News[]
  516.      */
  517.     public function getNews() {
  518.         return $this->news;
  519.     }
  520.     /**
  521.      * @param JobPosition $jobPosition
  522.      *
  523.      * @return Company
  524.      */
  525.     public function addJobPosition(JobPosition $jobPosition): self
  526.     {
  527.         if (!$this->jobPositions->contains($jobPosition)) {
  528.             $this->jobPositions[] = $jobPosition;
  529.         }
  530.         return $this;
  531.     }
  532.     /**
  533.      * @param JobPosition $jobPosition
  534.      *
  535.      * @return Company
  536.      */
  537.     public function removeJobPosition(JobPosition $jobPosition): self
  538.     {
  539.         if ($this->jobPositions->contains($jobPosition)) {
  540.             $this->jobPositions->removeElement($jobPosition);
  541.         }
  542.         return $this;
  543.     }
  544.     /**
  545.      * @return Collection|CompanySubscription[]
  546.      */
  547.     public function getSubscriptions() {
  548.         return $this->subscriptions;
  549.     }
  550.     /**
  551.      * @return Collection|CompanySubscription[]
  552.      */
  553.     public function getActiveSubscriptions() {
  554.         $activeSubscriptions = new ArrayCollection();
  555.         foreach ($this->subscriptions as $subscription) {
  556.             if ($subscription->isActive() && !$subscription->isExpired()) {
  557.                 $paymentPlan = $subscription->getPaymentPlan();
  558.                 
  559.                 $subscription->setExclusive($paymentPlan->isExclusive());
  560.                 $subscription->setAddon($paymentPlan->isAddon());
  561.                 $activeSubscriptions->add($subscription);
  562.             }
  563.         }
  564.         return $activeSubscriptions;
  565.     }
  566.     /**
  567.      * @return CompanySubscription
  568.      */
  569.     public function getOneActiveSubscription() {
  570.         $activeSubscriptions = [];
  571.         if (count($this->subscriptions) > 0) {
  572.             $currentDate = new \DateTime;
  573.             foreach ($this->subscriptions as $subscription) {
  574.                 if ($subscription->isActive() && !$subscription->isExpired() && 
  575.                     ($subscription->getValidTo() >= $currentDate || $subscription->getValidTo() == null) && $subscription->getCreatedAt() < $currentDate &&
  576.                     ($subscription->getOffers() > $subscription->getPublishedOffers() || $subscription->getOffers() == null) 
  577.                 ) {
  578.                     $paymentPlan = $subscription->getPaymentPlan();
  579.                     if (!$paymentPlan->isPromotedJobPackage()) {
  580.                         $subscription->setExclusive($paymentPlan->isExclusive());
  581.                         $subscription->setAddon($paymentPlan->isAddon());
  582.                         $subscription->planName = $paymentPlan->getName();
  583.                         $subscription->planId = $paymentPlan->getId();
  584.         
  585.                         $activeSubscriptions[] = $subscription;
  586.                     }
  587.                 }
  588.             }
  589.             if (count($activeSubscriptions)) {
  590.                 usort($activeSubscriptions, function ($b, $a) {
  591.                     return $a->getCreatedAt() == $b->getCreatedAt() ? 0 : ($b->getCreatedAt() > $a->getCreatedAt() ? -1 : 1);
  592.                 });
  593.                 return $activeSubscriptions[0];
  594.             }
  595.         }
  596.         return count($activeSubscriptions) > 0 ? $activeSubscriptions[0] : null;
  597.     }
  598.     /**
  599.      * @param CompanySubscription $subscription
  600.      *
  601.      * @return Company
  602.      */
  603.     public function addSubscription(CompanySubscription $subscription): self
  604.     {
  605.         if (!$this->subscriptions->contains($subscription)) {
  606.             $this->subscriptions[] = $subscription;
  607.         }
  608.         return $this;
  609.     }
  610.     /**
  611.      * @param CompanySubscription $subscription
  612.      *
  613.      * @return Company
  614.      */
  615.     public function removeSubscription(CompanySubscription $subscription): self
  616.     {
  617.         if ($this->subscriptions->contains($subscription)) {
  618.             $this->subscriptions->removeElement($subscription);
  619.         }
  620.         return $this;
  621.     }
  622.     /**
  623.      * @return Collection|Candidate[]
  624.      */
  625.     public function getFollowers(): Collection
  626.     {
  627.         return $this->followers;
  628.     }
  629.     /**
  630.      * @param Candidate $follower
  631.      *
  632.      * @return Company
  633.      */
  634.     public function addFollower(Candidate $follower): self
  635.     {
  636.         if (!$this->followers->contains($follower)) {
  637.             $this->followers[] = $follower;
  638.         }
  639.         return $this;
  640.     }
  641.     /**
  642.      * @param Candidate $follower
  643.      *
  644.      * @return Company
  645.      */
  646.     public function removeFollower(Candidate $follower): self
  647.     {
  648.         if ($this->followers->contains($follower)) {
  649.             $this->followers->removeElement($follower);
  650.         }
  651.         return $this;
  652.     }
  653.     /**
  654.      * @param ArrayCollection $followers
  655.      *
  656.      * @return Company
  657.      */
  658.     public function setFollowers(ArrayCollection $followers): self
  659.     {
  660.         $this->followers = $followers;
  661.         return $this;
  662.     }
  663.     /**
  664.      * @return Collection|CompanyAdvantage[]
  665.      */
  666.     public function getAdvantages()
  667.     {
  668.         $array = $this->advantages->toArray();
  669.         $arrayAdvantages = [];
  670.         foreach ($array as $key => $value) {
  671.             $arrayAdvantages[] = $value->advantage->getName();
  672.         }
  673.         return $arrayAdvantages;
  674.     }
  675.     /**
  676.      * @return Collection|CompanyAdvantage[]
  677.      */
  678.     public function getAdvantagesCollection(): Collection
  679.     {
  680.         return $this->advantages;
  681.     }
  682.     /**
  683.      * @param CompanyAdvantage $advantage
  684.      *
  685.      * @return Company
  686.      */
  687.     public function addAdvantage(CompanyAdvantage $advantage): self
  688.     {
  689.         if (!$this->advantages->contains($advantage)) {
  690.             $this->advantages[] = $advantage;
  691.         }
  692.         return $this;
  693.     }
  694.     /**
  695.      * @param CompanyAdvantage $advantage
  696.      *
  697.      * @return Company
  698.      */
  699.     public function removeAdvantage(CompanyAdvantage $advantage): self
  700.     {
  701.         if ($this->advantages->contains($advantage)) {
  702.             $this->advantages->removeElement($advantage);
  703.         }
  704.         return $this;
  705.     }
  706.     /**
  707.      * @param ArrayCollection $advantages
  708.      *
  709.      * @return Company
  710.      */
  711.     public function setAdvantages(ArrayCollection $advantages): self
  712.     {
  713.         $this->advantages = $advantages;
  714.         return $this;
  715.     }
  716.     /**
  717.      * @return File|null
  718.      */
  719.     public function getLogo(){
  720.         return $this->getFileService()->getFile($this, self::FILE_LOGO);
  721.     }
  722.     public function setLogo(?UploadedFile $file){
  723.         if ($file) {
  724.             $oldFile = $this->getFileService()->getFile($this, self::FILE_LOGO);
  725.             $newFile = $this->getFileService()->upload($file, $this, self::FILE_LOGO, true, null, $this->getUser()->getId());
  726.             if($newFile && $oldFile){
  727.                 $this->getFileService()->delete($oldFile);
  728.             }
  729.         }
  730.         return $this;
  731.     }
  732.     public function removeLogo(){
  733.         $file = $this->getFileService()->getFile($this, self::FILE_LOGO);
  734.         if($file) {
  735.             $this->getFileService()->delete($file);
  736.         }
  737.         return $this;
  738.     }
  739.     public function getCover(){
  740.         return $this->getFileService()->getFile($this, self::FILE_COVER);
  741.     }
  742.     public function setCover(?UploadedFile $file){
  743.         if ($file) {
  744.             $oldFile = $this->getFileService()->getFile($this, self::FILE_COVER);
  745.             $newFile = $this->getFileService()->upload($file, $this, self::FILE_COVER, true, null, $this->getUser()->getId());
  746.             if ($newFile && $oldFile){
  747.                 $this->getFileService()->delete($oldFile);
  748.             }
  749.         }
  750.         return $this;
  751.     }
  752.     public function removeCover(){
  753.         $file = $this->getFileService()->getFile($this, self::FILE_COVER);
  754.         if ($file) {
  755.             $this->getFileService()->delete($file);
  756.         }
  757.         return $this;
  758.     }
  759.     public function getPdf(){
  760.         return $this->getFileService()->getFile($this, self::FILE_PDF);
  761.     }
  762.     public function setPdf(?UploadedFile $file){
  763.         if ($file) {
  764.             $oldFile = $this->getFileService()->getFile($this, self::FILE_PDF);
  765.             $newFile = $this->getFileService()->upload($file, $this, self::FILE_PDF);
  766.             if ($newFile && $oldFile){
  767.                 $this->getFileService()->delete($oldFile);
  768.             }
  769.         }
  770.         return $this;
  771.     }
  772.     public function removePdf(){
  773.         $file = $this->getFileService()->getFile($this, self::FILE_PDF);
  774.         if ($file) {
  775.             $this->getFileService()->delete($file);
  776.         }
  777.         return $this;
  778.     }
  779.     public function getPdfPresence(){
  780.         if ($this->getFileService()->getFile($this, self::FILE_PDF)) {
  781.             $companyHasPdf = 'Yes';
  782.             return $companyHasPdf;
  783.         } 
  784.         return null;
  785.     }
  786.     
  787.     public function getStatus(): ?int
  788.     {
  789.         return $this->status;
  790.     }
  791.     public function setStatus(int $status): self
  792.     {
  793.         if (!array_key_exists($status, self::STATUSES)){
  794.             throw new ValidatorException("Company status is not valid");
  795.         }
  796.         
  797.         $this->status = $status;
  798.         return $this;
  799.     }
  800.     /**
  801.      * @return bool
  802.      */
  803.     public function getMkariera(): bool {
  804.         return $this->mkariera;
  805.     }
  806.     /**
  807.      * @param bool $mkariera
  808.      *
  809.      * @return self
  810.      */
  811.     public function setMkariera(bool $mkariera): self {
  812.         $this->mkariera = $mkariera;
  813.         return $this;
  814.     }
  815.     public function getPublication(): ?string
  816.     {
  817.         return $this->publication;
  818.     }
  819.     public function setPublication(?string $publication): self
  820.     {
  821.         $this->publication = $publication;
  822.         return $this;
  823.     }
  824.     /**
  825.      * @return Collection|CompanyAboutUs[]
  826.      */
  827.     public function getAboutUs(): Collection
  828.     {
  829.         return $this->aboutUs;
  830.     }
  831.     /**
  832.      * @param CompanyAboutUs $aboutus
  833.      *
  834.      * @return Company
  835.      */
  836.     public function addAboutUs(CompanyAboutUs $aboutUs): self
  837.     {
  838.         if (!$this->aboutUs->contains($aboutUs)) {
  839.             $this->aboutUs[] = $aboutUs;
  840.         }
  841.         return $this;
  842.     }
  843.     /**
  844.      * @param CompanyAboutUs $aboutus
  845.      *
  846.      * @return Company
  847.      */
  848.     public function removeAboutUs(CompanyAboutUs $aboutUs): self
  849.     {
  850.         if ($this->aboutUs->contains($aboutUs)) {
  851.             $this->aboutUs->removeElement($aboutUs);
  852.         }
  853.         return $this;
  854.     }
  855.     /**
  856.      * @param ArrayCollection $aboutUs
  857.      *
  858.      * @return Company
  859.      */
  860.     public function setAboutUs(ArrayCollection $aboutUs): self
  861.     {
  862.         $this->aboutUs = $aboutUs;
  863.         return $this;
  864.     }
  865.     /**
  866.      * @return Collection|CompanyMosaic[]
  867.      */
  868.     public function getMosaic(): Collection
  869.     {
  870.         return $this->mosaic;
  871.     }
  872.     /**
  873.      * @param CompanyMosaic $mosaic
  874.      *
  875.      * @return Company
  876.      */
  877.     public function addMosaic(CompanyMosaic $mosaic): self
  878.     {
  879.         if (!$this->mosaic->contains($mosaic)) {
  880.             $this->mosaic[] = $mosaic;
  881.         }
  882.         return $this;
  883.     }
  884.     /**
  885.      * @param CompanyMosaic $mosaic
  886.      *
  887.      * @return Company
  888.      */
  889.     public function removeMosaic(CompanyMosaic $mosaic): self
  890.     {
  891.         if ($this->mosaic->contains($mosaic)) {
  892.             $this->mosaic->removeElement($mosaic);
  893.         }
  894.         return $this;
  895.     }
  896.     /**
  897.      * @param ArrayCollection $mosaicCollection
  898.      *
  899.      * @return Company
  900.      */
  901.     public function setMosaic(ArrayCollection $mosaicCollection): self
  902.     {
  903.         $this->mosaic = $mosaicCollection;
  904.         return $this;
  905.     }
  906.     /**
  907.      * @return Collection|CompanyGallery[]
  908.      */
  909.     public function getGallery(): Collection
  910.     {
  911.         return $this->gallery;
  912.     }
  913.     /**
  914.      * @param CompanyGallery $gallery
  915.      *
  916.      * @return Company
  917.      */
  918.     public function addGallery(CompanyGallery $gallery): self
  919.     {
  920.         if (!$this->gallery->contains($gallery)) {
  921.             $this->gallery[] = $gallery;
  922.         }
  923.         return $this;
  924.     }
  925.     /**
  926.      * @param CompanyGalery $gallery
  927.      *
  928.      * @return Company
  929.      */
  930.     public function removeGallery(CompanyGallery $gallery): self
  931.     {
  932.         if ($this->gallery->contains($gallery)) {
  933.             $this->gallery->removeElement($gallery);
  934.         }
  935.         return $this;
  936.     }
  937.     /**
  938.      * @param ArrayCollection $galleryCollection
  939.      *
  940.      * @return Company
  941.      */
  942.     public function setGallery(ArrayCollection $galleryCollection): self
  943.     {
  944.         $this->gallery = $galleryCollection;
  945.         return $this;
  946.     }
  947.     /**
  948.      * Get the value of coverThumbnail
  949.      *
  950.      * @return  string|null
  951.      */ 
  952.     public function getCoverThumbnail()
  953.     {
  954.         return $this->coverThumbnail;
  955.     }
  956.     /**
  957.      * Set the value of coverThumbnail
  958.      *
  959.      * @param  string|null  $coverThumbnail
  960.      *
  961.      * @return  self
  962.      */ 
  963.     public function setCoverThumbnail(?string $coverThumbnail)
  964.     {
  965.         $this->coverThumbnail = $coverThumbnail;
  966.         return $this;
  967.     }
  968.     /**
  969.      * Get the value of coverImageFile
  970.      *
  971.      * @return  File|null
  972.      */ 
  973.     public function getCoverImageFile()
  974.     {
  975.         return $this->coverImageFile;
  976.     }
  977.     /**
  978.      * Set the value of coverImageFile
  979.      *
  980.      * @return  self
  981.      */ 
  982.     public function setCoverImageFile(?UploadedFile $coverImageFile = null)
  983.     {
  984.         $this->coverImageFile = $coverImageFile;
  985.         if ($coverImageFile) {
  986.             $this->setCover($coverImageFile);
  987.             $this->imageUpdatedAt = (new \DateTime());
  988.         }
  989.         return $this;
  990.     }
  991.       /**
  992.      * Get the value of logoThumbnail
  993.      *
  994.      * @return  string|null
  995.      */ 
  996.     public function getLogoThumbnail()
  997.     {
  998.         return $this->logoThumbnail;
  999.     }
  1000.     /**
  1001.      * Set the value of logoThumbnail
  1002.      *
  1003.      * @param  string|null  $logoThumbnail
  1004.      *
  1005.      * @return  self
  1006.      */ 
  1007.     public function setLogoThumbnail($logoThumbnail)
  1008.     {
  1009.         $this->logoThumbnail = $logoThumbnail;
  1010.         return $this;
  1011.     }
  1012.     /**
  1013.      * Get the value of logoImageFile
  1014.      *
  1015.      * @return  File|null
  1016.      */ 
  1017.     public function getLogoImageFile()
  1018.     {
  1019.         return $this->logoImageFile;
  1020.     }
  1021.     /**
  1022.      * Set the value of logoImageFile
  1023.      *
  1024.      * @return  self
  1025.      */ 
  1026.     public function setLogoImageFile(?UploadedFile  $logoImageFile = null)
  1027.     {
  1028.         $this->logoImageFile = $logoImageFile;
  1029.         if ($logoImageFile) {
  1030.             $this->setLogo($logoImageFile);
  1031.             $this->imageUpdatedAt = (new \DateTime());
  1032.         }
  1033.         return $this;
  1034.     }
  1035.     /**
  1036.      * Get the value of imageUpdatedAt
  1037.      */ 
  1038.     public function getImageUpdatedAt()
  1039.     {
  1040.         return $this->imageUpdatedAt;
  1041.     }
  1042.      /**
  1043.      * Get the value of pdfPreview
  1044.      *
  1045.      * @return  string|null
  1046.      */ 
  1047.     public function getPdfPreview()
  1048.     {
  1049.         return $this->pdfPreview;
  1050.     }
  1051.     /**
  1052.      * Set the value of pdfPreview
  1053.      *
  1054.      * @param  string|null  $pdfPreview
  1055.      *
  1056.      * @return  self
  1057.      */ 
  1058.     public function setPdfPreview($pdfPreview)
  1059.     {
  1060.         $this->pdfPreview = $pdfPreview;
  1061.         return $this;
  1062.     }
  1063.     /**
  1064.      * Get the value of pdfFile
  1065.      *
  1066.      * @return  File|null
  1067.      */ 
  1068.     public function getPdfFile()
  1069.     {
  1070.         return $this->pdfFile;
  1071.     }
  1072.     /**
  1073.      * Set the value of pdfFile
  1074.      *
  1075.      * @return  self
  1076.      */ 
  1077.     public function setPdfFile(?UploadedFile $pdfFile = null)
  1078.     {
  1079.         $this->pdfFile = $pdfFile;
  1080.         if ($pdfFile) {
  1081.             $this->setPdf($pdfFile);
  1082.             $this->imageUpdatedAt = (new \DateTime());
  1083.         }
  1084.         return $this;
  1085.     }
  1086.     public function __toString() {
  1087.         return $this->getCompanyName();
  1088.     }
  1089.     public function sortCompanyAdvanteges($companyAdvantages) {
  1090.         usort($companyAdvantages, function ($a, $b) {
  1091.             return $a->getAdvantagePosition() == $b->getAdvantagePosition() ? 0 : ($b->getAdvantagePosition() > $a->getAdvantagePosition() ? -1 : 1);
  1092.         });
  1093.         return $companyAdvantages;
  1094.     }
  1095.     /**
  1096.      * Specify data which should be serialized to JSON
  1097.      *
  1098.      * @link https://php.net/manual/en/jsonserializable.jsonserialize.php
  1099.      * @return mixed data which can be serialized by <b>json_encode</b>,
  1100.      * which is a value of any type other than a resource.
  1101.      * @since 5.4.0
  1102.      */
  1103.     public function jsonSerialize() {
  1104.         return [
  1105.             'id' => $this->getId(),
  1106.             'companyName' => $this->getCompanyName(),
  1107.             'industry' => $this->getIndustry()->getValues(),
  1108.             'city' => $this->getCity(),
  1109.             'address' => $this->getAddress(),
  1110.             'companySize' => $this->getCompanySize(),
  1111.             'employeesAverageSize' => $this->getEmployeesAverageSize(),
  1112.             'website' => $this->getWebsite(),
  1113.             'email' => $this->getEmail(),
  1114.             'facebook' => $this->getFacebook(),
  1115.             'twitter' => $this->getTwitter(),
  1116.             'linkedin' => $this->getLinkedin(),
  1117.             'instagram' => $this->getInstagram(),
  1118.             'phone' => $this->getPhone(),
  1119.             'subdomain' => $this->getSubdomain(),
  1120.             'faq' => $this->getFaq(),
  1121.             'gdpr' => $this->getGdpr(),
  1122.             'featured' => $this->getFeatured(),
  1123.             'description' => $this->getDescription(),
  1124.             'billing' => $this->getBilling(),
  1125.             'logo' => $this->getLogo(),
  1126.             'cover' => $this->getCover(),
  1127.             'pdf' => $this->getPdf(),
  1128.             'status' => $this->getStatus(),
  1129.             'newsOption' => $this->getNewsOption(),
  1130.             'addon' => $this->getAddon(),
  1131.             'publication' => $this->getPublication(),
  1132.             'countActiveJobPositions' => $this->getJobPositions()->filter(function ($job) {return ($job->getStatus() === JobPosition::STATUS_ACTIVE && ($job->getValidTo() ? $job->getValidTo()->format('ymd') >= date('ymd') : false));})->count(),
  1133.             'aboutus' => $this->getAboutUs()->filter(function ($aboutUs) {return $aboutUs->getActive();})->getValues(),
  1134.             'advantages' => $this->sortCompanyAdvanteges($this->getAdvantagesCollection()->toArray()),
  1135.             'mosaic' => $this->getMosaic()->filter(function ($mosaic) {return $mosaic->getActive();})->getValues(),
  1136.             'gallery' => $this->getGallery()->filter(function ($gallery) {return $gallery->getActive();})->getValues(),
  1137.             'countFollowers' => count($this->getFollowers()->getValues())
  1138.         ];
  1139.     }
  1140. }