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.     public function __construct()
  206.     {
  207.         $this->image = new \Vich\UploaderBundle\Entity\File();
  208.     }
  209.     /**
  210.      * @ORM\PrePersist
  211.      */
  212.     public function setCreatedAtValue(): void
  213.     {
  214.         $this->setCreatedAt(new \DateTime("now"));
  215.         $this->setUpdatedAt(new \DateTime("now"));
  216.     }
  217.     /**
  218.      * @ORM\PreUpdate
  219.      */
  220.     public function setUpdatedAtValue(): void
  221.     {
  222.         $this->setUpdatedAt(new \DateTime("now"));
  223.     }
  224.     public function __toString()
  225.     {
  226.         return (string)$this->id;
  227.     }
  228.     /**
  229.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  230.      * of 'UploadedFile' is injected into this setter to trigger the  update. If this
  231.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  232.      * must be able to accept an instance of 'File' as the bundle will inject one here
  233.      * during Doctrine hydration.
  234.      *
  235.      * @param File|UploadedFile|null $imageFile
  236.      */
  237.     public function setImageFile(?File $imageFile null)
  238.     {
  239.         $this->imageFile $imageFile;
  240.         if (null !== $imageFile) {
  241.             // It is required that at least one field changes if you are using doctrine
  242.             // otherwise the event listeners won't be called and the file is lost
  243.             $this->setUpdatedAt(new \DateTime("now"));
  244.         }
  245.     }
  246.     public function getImageFile(): ?File
  247.     {
  248.         return $this->imageFile;
  249.     }
  250.     public function setImage(EmbeddedFile $image): void
  251.     {
  252.         $this->image $image;
  253.     }
  254.     public function getImage(): ?EmbeddedFile
  255.     {
  256.         return $this->image;
  257.     }
  258.     public function getImageBase64(?string $projectDir null): ?string
  259.     {
  260.         if (!$this->image || !$this->image->getName()) {
  261.             return null;
  262.         }
  263.         if (!$projectDir) {
  264.             return null// ou throw new \Exception('Project dir required');
  265.         }
  266.         $filePath $projectDir '/files/cvs/' $this->image->getName();
  267.         if (!file_exists($filePath)) {
  268.             return null;
  269.         }
  270.         $imageData file_get_contents($filePath);
  271.         $mimeType $this->image->getMimeType() ?? mime_content_type($filePath);
  272.         return 'data:' $mimeType ';base64,' base64_encode($imageData);
  273.     }
  274.     public function getId(): ?int
  275.     {
  276.         return $this->id;
  277.     }
  278.     public function getCreatedAt(): ?\DateTimeInterface
  279.     {
  280.         return $this->createdAt;
  281.     }
  282.     public function setCreatedAt(?\DateTimeInterface $createdAt): static
  283.     {
  284.         $this->createdAt $createdAt;
  285.         return $this;
  286.     }
  287.     public function getUpdatedAt(): ?\DateTimeInterface
  288.     {
  289.         return $this->updatedAt;
  290.     }
  291.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): static
  292.     {
  293.         $this->updatedAt $updatedAt;
  294.         return $this;
  295.     }
  296.     public function getCategory(): ?string
  297.     {
  298.         return $this->category;
  299.     }
  300.     public function setCategory(?string $category): static
  301.     {
  302.         $this->category $category;
  303.         return $this;
  304.     }
  305.     public function getCompanyName(): ?string
  306.     {
  307.         return $this->companyName;
  308.     }
  309.     public function setCompanyName(?string $companyName): static
  310.     {
  311.         $this->companyName $companyName;
  312.         return $this;
  313.     }
  314.     public function getAddress(): ?string
  315.     {
  316.         return $this->address;
  317.     }
  318.     public function setAddress(?string $address): static
  319.     {
  320.         $this->address $address;
  321.         return $this;
  322.     }
  323.     public function getCity(): ?string
  324.     {
  325.         return $this->city;
  326.     }
  327.     public function setCity(?string $city): static
  328.     {
  329.         $this->city $city;
  330.         return $this;
  331.     }
  332.     public function getZipcode(): ?string
  333.     {
  334.         return $this->zipcode;
  335.     }
  336.     public function setZipcode(?string $zipcode): static
  337.     {
  338.         $this->zipcode $zipcode;
  339.         return $this;
  340.     }
  341.     public function getCountry(): ?string
  342.     {
  343.         return $this->country;
  344.     }
  345.     public function setCountry(?string $country): static
  346.     {
  347.         $this->country $country;
  348.         return $this;
  349.     }
  350.     public function getWebsite(): ?string
  351.     {
  352.         return $this->website;
  353.     }
  354.     public function setWebsite(?string $website): static
  355.     {
  356.         $this->website $website;
  357.         return $this;
  358.     }
  359.     public function getEmail(): ?string
  360.     {
  361.         return $this->email;
  362.     }
  363.     public function setEmail(?string $email): static
  364.     {
  365.         $this->email $email;
  366.         return $this;
  367.     }
  368.     public function getPhone(): ?string
  369.     {
  370.         return $this->phone;
  371.     }
  372.     public function setPhone(?string $phone): static
  373.     {
  374.         $this->phone $phone;
  375.         return $this;
  376.     }
  377.     public function getCompanyDescription(): ?string
  378.     {
  379.         return $this->companyDescription;
  380.     }
  381.     public function setCompanyDescription(?string $companyDescription): static
  382.     {
  383.         $this->companyDescription $companyDescription;
  384.         return $this;
  385.     }
  386.     public function getContactName(): ?string
  387.     {
  388.         return $this->contactName;
  389.     }
  390.     public function setContactName(?string $contactName): static
  391.     {
  392.         $this->contactName $contactName;
  393.         return $this;
  394.     }
  395.     public function getContactEmail(): ?string
  396.     {
  397.         return $this->contactEmail;
  398.     }
  399.     public function setContactEmail(?string $contactEmail): static
  400.     {
  401.         $this->contactEmail $contactEmail;
  402.         return $this;
  403.     }
  404.     public function getContactURL(): ?string
  405.     {
  406.         return $this->contactURL;
  407.     }
  408.     public function setContactURL(?string $contactURL): static
  409.     {
  410.         $this->contactURL $contactURL;
  411.         return $this;
  412.     }
  413.     public function isOnline(): ?bool
  414.     {
  415.         return $this->online;
  416.     }
  417.     public function setOnline(?bool $online): static
  418.     {
  419.         $this->online $online;
  420.         return $this;
  421.     }
  422.     public function getSlug(): ?string
  423.     {
  424.         return $this->slug;
  425.     }
  426.     public function setSlug(?string $slug): static
  427.     {
  428.         $this->slug $slug;
  429.         return $this;
  430.     }
  431.     public function getLocale(): ?string
  432.     {
  433.         return $this->locale;
  434.     }
  435.     public function setLocale(?string $locale): static
  436.     {
  437.         $this->locale $locale;
  438.         return $this;
  439.     }
  440.     public function getUser(): ?Users
  441.     {
  442.         return $this->user;
  443.     }
  444.     public function setUser(?Users $user): static
  445.     {
  446.         $this->user $user;
  447.         return $this;
  448.     }
  449.     public function getShortTitle(): ?string
  450.     {
  451.         return $this->shortTitle;
  452.     }
  453.     public function setShortTitle(?string $shortTitle): static
  454.     {
  455.         $this->shortTitle $shortTitle;
  456.         return $this;
  457.     }
  458.     public function getShortDescription(): ?string
  459.     {
  460.         return $this->shortDescription;
  461.     }
  462.     public function setShortDescription(?string $shortDescription): static
  463.     {
  464.         $this->shortDescription $shortDescription;
  465.         return $this;
  466.     }
  467.     public function getViews(): ?int
  468.     {
  469.         return $this->views;
  470.     }
  471.     public function setViews(?int $views): static
  472.     {
  473.         $this->views $views;
  474.         return $this;
  475.     }
  476.     public function isValidation(): ?bool
  477.     {
  478.         return $this->validation;
  479.     }
  480.     public function setValidation(?bool $validation): static
  481.     {
  482.         $this->validation $validation;
  483.         return $this;
  484.     }
  485.     public function isVerification(): ?bool
  486.     {
  487.         return $this->verification;
  488.     }
  489.     public function setVerification(?bool $verification): static
  490.     {
  491.         $this->verification $verification;
  492.         return $this;
  493.     }
  494.     public function getPointx(): ?string
  495.     {
  496.         return $this->pointx;
  497.     }
  498.     public function setPointx(?string $pointx): static
  499.     {
  500.         $this->pointx $pointx;
  501.         return $this;
  502.     }
  503.     public function getPointy(): ?string
  504.     {
  505.         return $this->pointy;
  506.     }
  507.     public function setPointy(?string $pointy): static
  508.     {
  509.         $this->pointy $pointy;
  510.         return $this;
  511.     }
  512. }