src/Entity/Cvs/Enterprises.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Cvs;
  3. use App\Entity\Core\Users;
  4. use App\Entity\Core\Agencies;
  5. use Doctrine\DBAL\Types\Types;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. use Symfony\Component\HttpFoundation\File\File;
  11. use Symfony\Component\HttpFoundation\File\UploadedFile;
  12. use Vich\UploaderBundle\Entity\File as EmbeddedFile;
  13. use Vich\UploaderBundle\Templating\Helper\UploaderHelper;
  14. /**
  15.  * Enterprises
  16.  *
  17.  * @ORM\Table("cvs_enterprises")
  18.  * @ORM\Entity(repositoryClass="App\Repository\Cvs\EnterprisesRepository")
  19.  * @ORM\HasLifecycleCallbacks()
  20.  * @Vich\Uploadable
  21.  */
  22. class Enterprises
  23. {
  24.     /**
  25.      * @var integer
  26.      *
  27.      * @ORM\Column(name="id", type="integer")
  28.      * @ORM\Id
  29.      * @ORM\GeneratedValue(strategy="AUTO")
  30.      */
  31.     protected $id;
  32.     /**
  33.      * @var string
  34.      *
  35.      * @ORM\Column(name="created_at", type="datetime", nullable=true, options={"comment":"Date de création"})
  36.      */
  37.     private $createdAt;
  38.     /**
  39.      * @var string
  40.      *
  41.      * @ORM\Column(name="updated_at", type="datetime", nullable=true, options={"comment":"Date de mise à jour"})
  42.      */
  43.     private $updatedAt;
  44.     /**
  45.      * @var string
  46.      *
  47.      * @ORM\Column(name="category", type="string", length=255, nullable=true)
  48.      */
  49.     private $category;
  50.     /**
  51.      * @var string
  52.      *
  53.      * @ORM\Column(name="short_title", type="text", nullable=true)
  54.      */
  55.     private $shortTitle;
  56.     /**
  57.      * @var string
  58.      *
  59.      * @ORM\Column(name="short_description", type="text", nullable=true)
  60.      */
  61.     private $shortDescription;
  62.     /**
  63.      * @var string
  64.      *
  65.      * @ORM\Column(name="company_name", type="string", length=255, nullable=true)
  66.      */
  67.     private $companyName;
  68.     /**
  69.      * @var string
  70.      *
  71.      * @ORM\Column(name="address", type="string", length=255, nullable=true)
  72.      */
  73.     private $address;
  74.     /**
  75.      * @var string
  76.      *
  77.      * @ORM\Column(name="city", type="string", length=255, nullable=true)
  78.      */
  79.     private $city;
  80.     /**
  81.      * @var string
  82.      *
  83.      * @ORM\Column(name="zipcode", type="string", length=255, nullable=true)
  84.      */
  85.     private $zipcode;
  86.     /**
  87.      * @var string
  88.      *
  89.      * @ORM\Column(name="country", type="string", length=255, nullable=true)
  90.      */
  91.     private $country;
  92.     /**
  93.      * @var string
  94.      *
  95.      * @ORM\Column(name="website", type="string", length=255, nullable=true)
  96.      */
  97.     private $website;
  98.     /**
  99.      * @var string
  100.      *
  101.      * @ORM\Column(name="email", type="string", length=255, nullable=true)
  102.      */
  103.     private $email;
  104.     /**
  105.      * @var string
  106.      *
  107.      * @ORM\Column(name="phone", type="string", length=255, nullable=true)
  108.      */
  109.     private $phone;
  110.     /**
  111.      * @var string
  112.      *
  113.      * @ORM\Column(name="company_description", type="text", nullable=true)
  114.      */
  115.     private $companyDescription;
  116.     /**
  117.      * @var string
  118.      *
  119.      * @ORM\Column(name="contact_name", type="string", length=255, nullable=true)
  120.      */
  121.     private $contactName;
  122.     /**
  123.      * @var string
  124.      *
  125.      * @ORM\Column(name="contact_email", type="string", length=255, nullable=true)
  126.      */
  127.     private $contactEmail;
  128.     /**
  129.      * @var string
  130.      *
  131.      * @ORM\Column(name="contact_url", type="string", length=255, nullable=true)
  132.      */
  133.     private $contactURL;
  134.     /**
  135.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  136.      *
  137.      * @Vich\UploadableField(mapping="enterprises_logo", fileNameProperty="image.name", size="image.size", mimeType="image.mimeType", originalName="image.originalName", dimensions="image.dimensions")
  138.      *
  139.      * @var File|null
  140.      */
  141.     private $imageFile;
  142.     /**
  143.      * @ORM\Embedded(class="Vich\UploaderBundle\Entity\File")
  144.      *
  145.      * @var EmbeddedFile
  146.      */
  147.     private $image;
  148.     /**
  149.      * @var string
  150.      *
  151.      * @ORM\Column(name="online", type="boolean", nullable=true)
  152.      */
  153.     private $online;
  154.     /**
  155.      * @var string
  156.      *
  157.      * @ORM\Column(name="validation", type="boolean", nullable=true)
  158.      */
  159.     private $validation;
  160.     /**
  161.      * @var string
  162.      *
  163.      * @ORM\Column(name="verification", type="boolean", nullable=true)
  164.      */
  165.     private $verification;
  166.     /**
  167.      * @var \Users
  168.      *
  169.      * @ORM\ManyToOne(targetEntity="App\Entity\Core\Users")
  170.      * @ORM\JoinColumns({
  171.      *   @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=true)
  172.      * })
  173.      */
  174.     protected $user;
  175.     /**
  176.      * @var string
  177.      *
  178.      * @ORM\Column(name="slug", type="string", length=255, nullable=true)
  179.      */
  180.     private $slug;
  181.     /**
  182.      * @var string
  183.      *
  184.      * @ORM\Column(name="locale", type="string", length=255, nullable=true)
  185.      */
  186.     private $locale;
  187.     /**
  188.      * @var string
  189.      *
  190.      * @ORM\Column(name="views", type="integer", length=11, nullable=true)
  191.      */
  192.     private $views;
  193.     /**
  194.      * @var string
  195.      *
  196.      * @ORM\Column(name="pointx", type="string", length=255, nullable=true)
  197.      */
  198.     private $pointx;
  199.     /**
  200.      * @var string
  201.      *
  202.      * @ORM\Column(name="pointy", type="string", length=255, nullable=true)
  203.      */
  204.     private $pointy;
  205.     /**
  206.      * @var \Agencies
  207.      *
  208.      * @ORM\ManyToOne(targetEntity="App\Entity\Core\Agencies")
  209.      * @ORM\JoinColumns({
  210.      *   @ORM\JoinColumn(name="agency_id", referencedColumnName="id", nullable=true)
  211.      * })
  212.      */
  213.     protected $agency;
  214.     public function __construct()
  215.     {
  216.         $this->image = new \Vich\UploaderBundle\Entity\File();
  217.     }
  218.     /**
  219.      * @ORM\PrePersist
  220.      */
  221.     public function setCreatedAtValue(): void
  222.     {
  223.         $this->setCreatedAt(new \DateTime("now"));
  224.         $this->setUpdatedAt(new \DateTime("now"));
  225.     }
  226.     /**
  227.      * @ORM\PreUpdate
  228.      */
  229.     public function setUpdatedAtValue(): void
  230.     {
  231.         $this->setUpdatedAt(new \DateTime("now"));
  232.     }
  233.     public function __toString()
  234.     {
  235.         return (string)$this->id;
  236.     }
  237.     /**
  238.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  239.      * of 'UploadedFile' is injected into this setter to trigger the  update. If this
  240.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  241.      * must be able to accept an instance of 'File' as the bundle will inject one here
  242.      * during Doctrine hydration.
  243.      *
  244.      * @param File|UploadedFile|null $imageFile
  245.      */
  246.     public function setImageFile(?File $imageFile null)
  247.     {
  248.         $this->imageFile $imageFile;
  249.         if (null !== $imageFile) {
  250.             // It is required that at least one field changes if you are using doctrine
  251.             // otherwise the event listeners won't be called and the file is lost
  252.             $this->setUpdatedAt(new \DateTime("now"));
  253.         }
  254.     }
  255.     public function getImageFile(): ?File
  256.     {
  257.         return $this->imageFile;
  258.     }
  259.     public function setImage(EmbeddedFile $image): void
  260.     {
  261.         $this->image $image;
  262.     }
  263.     public function getImage(): ?EmbeddedFile
  264.     {
  265.         return $this->image;
  266.     }
  267.     public function getImageBase64(?string $projectDir null): ?string
  268.     {
  269.         if (!$this->image || !$this->image->getName()) {
  270.             return null;
  271.         }
  272.         if (!$projectDir) {
  273.             return null// ou throw new \Exception('Project dir required');
  274.         }
  275.         $filePath $projectDir '/files/cvs/' $this->image->getName();
  276.         if (!file_exists($filePath)) {
  277.             return null;
  278.         }
  279.         $imageData file_get_contents($filePath);
  280.         $mimeType $this->image->getMimeType() ?? mime_content_type($filePath);
  281.         return 'data:' $mimeType ';base64,' base64_encode($imageData);
  282.     }
  283.     public function getId(): ?int
  284.     {
  285.         return $this->id;
  286.     }
  287.     public function getCreatedAt(): ?\DateTimeInterface
  288.     {
  289.         return $this->createdAt;
  290.     }
  291.     public function setCreatedAt(?\DateTimeInterface $createdAt): static
  292.     {
  293.         $this->createdAt $createdAt;
  294.         return $this;
  295.     }
  296.     public function getUpdatedAt(): ?\DateTimeInterface
  297.     {
  298.         return $this->updatedAt;
  299.     }
  300.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): static
  301.     {
  302.         $this->updatedAt $updatedAt;
  303.         return $this;
  304.     }
  305.     public function getCategory(): ?string
  306.     {
  307.         return $this->category;
  308.     }
  309.     public function setCategory(?string $category): static
  310.     {
  311.         $this->category $category;
  312.         return $this;
  313.     }
  314.     public function getCompanyName(): ?string
  315.     {
  316.         return $this->companyName;
  317.     }
  318.     public function setCompanyName(?string $companyName): static
  319.     {
  320.         $this->companyName $companyName;
  321.         return $this;
  322.     }
  323.     public function getAddress(): ?string
  324.     {
  325.         return $this->address;
  326.     }
  327.     public function setAddress(?string $address): static
  328.     {
  329.         $this->address $address;
  330.         return $this;
  331.     }
  332.     public function getCity(): ?string
  333.     {
  334.         return $this->city;
  335.     }
  336.     public function setCity(?string $city): static
  337.     {
  338.         $this->city $city;
  339.         return $this;
  340.     }
  341.     public function getZipcode(): ?string
  342.     {
  343.         return $this->zipcode;
  344.     }
  345.     public function setZipcode(?string $zipcode): static
  346.     {
  347.         $this->zipcode $zipcode;
  348.         return $this;
  349.     }
  350.     public function getCountry(): ?string
  351.     {
  352.         return $this->country;
  353.     }
  354.     public function setCountry(?string $country): static
  355.     {
  356.         $this->country $country;
  357.         return $this;
  358.     }
  359.     public function getWebsite(): ?string
  360.     {
  361.         return $this->website;
  362.     }
  363.     public function setWebsite(?string $website): static
  364.     {
  365.         $this->website $website;
  366.         return $this;
  367.     }
  368.     public function getEmail(): ?string
  369.     {
  370.         return $this->email;
  371.     }
  372.     public function setEmail(?string $email): static
  373.     {
  374.         $this->email $email;
  375.         return $this;
  376.     }
  377.     public function getPhone(): ?string
  378.     {
  379.         return $this->phone;
  380.     }
  381.     public function setPhone(?string $phone): static
  382.     {
  383.         $this->phone $phone;
  384.         return $this;
  385.     }
  386.     public function getCompanyDescription(): ?string
  387.     {
  388.         return $this->companyDescription;
  389.     }
  390.     public function setCompanyDescription(?string $companyDescription): static
  391.     {
  392.         $this->companyDescription $companyDescription;
  393.         return $this;
  394.     }
  395.     public function getContactName(): ?string
  396.     {
  397.         return $this->contactName;
  398.     }
  399.     public function setContactName(?string $contactName): static
  400.     {
  401.         $this->contactName $contactName;
  402.         return $this;
  403.     }
  404.     public function getContactEmail(): ?string
  405.     {
  406.         return $this->contactEmail;
  407.     }
  408.     public function setContactEmail(?string $contactEmail): static
  409.     {
  410.         $this->contactEmail $contactEmail;
  411.         return $this;
  412.     }
  413.     public function getContactURL(): ?string
  414.     {
  415.         return $this->contactURL;
  416.     }
  417.     public function setContactURL(?string $contactURL): static
  418.     {
  419.         $this->contactURL $contactURL;
  420.         return $this;
  421.     }
  422.     public function isOnline(): ?bool
  423.     {
  424.         return $this->online;
  425.     }
  426.     public function setOnline(?bool $online): static
  427.     {
  428.         $this->online $online;
  429.         return $this;
  430.     }
  431.     public function getSlug(): ?string
  432.     {
  433.         return $this->slug;
  434.     }
  435.     public function setSlug(?string $slug): static
  436.     {
  437.         $this->slug $slug;
  438.         return $this;
  439.     }
  440.     public function getLocale(): ?string
  441.     {
  442.         return $this->locale;
  443.     }
  444.     public function setLocale(?string $locale): static
  445.     {
  446.         $this->locale $locale;
  447.         return $this;
  448.     }
  449.     public function getUser(): ?Users
  450.     {
  451.         return $this->user;
  452.     }
  453.     public function setUser(?Users $user): static
  454.     {
  455.         $this->user $user;
  456.         return $this;
  457.     }
  458.     public function getShortTitle(): ?string
  459.     {
  460.         return $this->shortTitle;
  461.     }
  462.     public function setShortTitle(?string $shortTitle): static
  463.     {
  464.         $this->shortTitle $shortTitle;
  465.         return $this;
  466.     }
  467.     public function getShortDescription(): ?string
  468.     {
  469.         return $this->shortDescription;
  470.     }
  471.     public function setShortDescription(?string $shortDescription): static
  472.     {
  473.         $this->shortDescription $shortDescription;
  474.         return $this;
  475.     }
  476.     public function getViews(): ?int
  477.     {
  478.         return $this->views;
  479.     }
  480.     public function setViews(?int $views): static
  481.     {
  482.         $this->views $views;
  483.         return $this;
  484.     }
  485.     public function isValidation(): ?bool
  486.     {
  487.         return $this->validation;
  488.     }
  489.     public function setValidation(?bool $validation): static
  490.     {
  491.         $this->validation $validation;
  492.         return $this;
  493.     }
  494.     public function isVerification(): ?bool
  495.     {
  496.         return $this->verification;
  497.     }
  498.     public function setVerification(?bool $verification): static
  499.     {
  500.         $this->verification $verification;
  501.         return $this;
  502.     }
  503.     public function getPointx(): ?string
  504.     {
  505.         return $this->pointx;
  506.     }
  507.     public function setPointx(?string $pointx): static
  508.     {
  509.         $this->pointx $pointx;
  510.         return $this;
  511.     }
  512.     public function getPointy(): ?string
  513.     {
  514.         return $this->pointy;
  515.     }
  516.     public function setPointy(?string $pointy): static
  517.     {
  518.         $this->pointy $pointy;
  519.         return $this;
  520.     }
  521.     public function getAgency(): ?Agencies
  522.     {
  523.         return $this->agency;
  524.     }
  525.     public function setAgency(?Agencies $agency): static
  526.     {
  527.         $this->agency $agency;
  528.         return $this;
  529.     }
  530. }