src/Entity/Activity.php line 26

Open in your IDE?
  1. <?php
  2.     namespace App\Entity;
  3.     use App\Repository\ActivityRepository;
  4.     use App\Traits\DateTrait;
  5.     use DateTimeImmutable;
  6.     use Doctrine\Common\Collections\ArrayCollection;
  7.     use Doctrine\Common\Collections\Collection;
  8.     use Doctrine\ORM\Mapping as ORM;
  9.     use JMS\Serializer\Annotation as Serializer;
  10.     use JMS\Serializer\Annotation\Expose;
  11.     use JMS\Serializer\Annotation\Groups;
  12.     use Symfony\Component\HttpFoundation\File\File;
  13.     use Symfony\Component\HttpFoundation\File\UploadedFile;
  14.     use Vich\UploaderBundle\Mapping\Annotation as Vich;
  15.     /**
  16.      * @ORM\Entity(repositoryClass=ActivityRepository::class)
  17.      *
  18.      * @ORM\HasLifecycleCallbacks
  19.      *
  20.      * @Serializer\ExclusionPolicy("ALL")
  21.      * @Vich\Uploadable
  22.      */
  23.     class Activity
  24.     {
  25.         /**
  26.          * @ORM\Id
  27.          * @ORM\GeneratedValue
  28.          * @ORM\Column(type="integer")
  29.          *
  30.          * @Expose
  31.          * @Groups({"activity"})
  32.          */
  33.         private $id;
  34.         /**
  35.          * @ORM\Column(type="string", length=255)
  36.          *
  37.          * @Expose
  38.          * @Groups({"activity"})
  39.          */
  40.         private $name;
  41.         /**
  42.          * @ORM\Column(type="string", length=255, nullable=true)
  43.          *
  44.          * @Expose
  45.          * @Groups({"activity"})
  46.          */
  47.         private $path;
  48.         // Vich Uploader
  49.         /**
  50.          * @Vich\UploadableField(mapping="activity_images", fileNameProperty="path")
  51.          * @var File
  52.          */
  53.         private $imageFile;
  54.         /**
  55.          * @ORM\Column(type="boolean", nullable=true)
  56.          *
  57.          * @Expose
  58.          * @Groups({"activity"})
  59.          */
  60.         private $mainActivity;
  61.         /**
  62.          * @ORM\OneToMany(targetEntity=Devis::class, mappedBy="mainActivity")
  63.          * @ORM\JoinColumn(nullable=true)
  64.          *
  65.          */
  66.         private $mainDevis;
  67.         /**
  68.          * @ORM\OneToMany(targetEntity=Devis::class, mappedBy="secondaryActivity")
  69.          * @ORM\JoinColumn(nullable=true)
  70.          */
  71.         private $secondaryDevis;
  72.         /**
  73.          * @ORM\Column(type="boolean", nullable=true)
  74.          *
  75.          * @Expose
  76.          * @Groups({"activity"})
  77.          */
  78.         private $enabled;
  79.         /**
  80.          * @ORM\Column(type="string", length=255, nullable=true)
  81.          */
  82.         private $slug;
  83.         use DateTrait;
  84.         public function __construct()
  85.         {
  86.             $this->mainDevis      = new ArrayCollection();
  87.             $this->secondaryDevis = new ArrayCollection();
  88.         }
  89.         public function getImageFile()
  90.         {
  91.             return $this->imageFile;
  92.         }
  93.         /**
  94.          * @param File|UploadedFile|null $imageFile
  95.          */
  96.         public function setImageFileFile $imageFile )
  97.         {
  98.             $this->imageFile $imageFile;
  99.             if ( NULL !== $imageFile ) {
  100.                 // It is required that at least one field changes if you are using doctrine
  101.                 // otherwise the event listeners won't be called and the file is lost
  102.                 $this->updatedAt = new DateTimeImmutable();
  103.             }
  104.             return $this;
  105.         }
  106.         public function getId(): ?int
  107.         {
  108.             return $this->id;
  109.         }
  110.         public function getName(): ?string
  111.         {
  112.             return $this->name;
  113.         }
  114.         public function setNamestring $name ): self
  115.         {
  116.             $this->name $name;
  117.             return $this;
  118.         }
  119.         public function getPath(): ?string
  120.         {
  121.             return $this->path;
  122.         }
  123.         public function setPathstring $path ): self
  124.         {
  125.             $this->path $path;
  126.             return $this;
  127.         }
  128.         /**
  129.          * @return Collection|Devis[]
  130.          */
  131.         public function getMainDevis(): Collection
  132.         {
  133.             return $this->mainDevis;
  134.         }
  135.         public function addMainDeviDevis $mainDevi ): self
  136.         {
  137.             if ( !$this->mainDevis->contains$mainDevi ) ) {
  138.                 $this->mainDevis[] = $mainDevi;
  139.                 $mainDevi->setMainActivity$this );
  140.             }
  141.             return $this;
  142.         }
  143.         public function removeMainDeviDevis $mainDevi ): self
  144.         {
  145.             if ( $this->mainDevis->removeElement$mainDevi ) ) {
  146.                 // set the owning side to null (unless already changed)
  147.                 if ( $mainDevi->getMainActivity() === $this ) {
  148.                     $mainDevi->setMainActivityNULL );
  149.                 }
  150.             }
  151.             return $this;
  152.         }
  153.         public function getMainActivity(): ?bool
  154.         {
  155.             return $this->mainActivity;
  156.         }
  157.         public function setMainActivity( ?bool $mainActivity ): self
  158.         {
  159.             $this->mainActivity $mainActivity;
  160.             return $this;
  161.         }
  162.         /**
  163.          * @return Collection|Devis[]
  164.          */
  165.         public function getSecondaryDevis(): Collection
  166.         {
  167.             return $this->secondaryDevis;
  168.         }
  169.         public function addSecondaryDeviDevis $secondaryDevi ): self
  170.         {
  171.             if ( !$this->secondaryDevis->contains$secondaryDevi ) ) {
  172.                 $this->secondaryDevis[] = $secondaryDevi;
  173.                 $secondaryDevi->setSecondaryActivity$this );
  174.             }
  175.             return $this;
  176.         }
  177.         public function removeSecondaryDeviDevis $secondaryDevi ): self
  178.         {
  179.             if ( $this->secondaryDevis->removeElement$secondaryDevi ) ) {
  180.                 // set the owning side to null (unless already changed)
  181.                 if ( $secondaryDevi->getSecondaryActivity() === $this ) {
  182.                     $secondaryDevi->setSecondaryActivityNULL );
  183.                 }
  184.             }
  185.             return $this;
  186.         }
  187.         public function getEnabled(): ?bool
  188.         {
  189.             return $this->enabled;
  190.         }
  191.         public function setEnabled( ?bool $enabled ): self
  192.         {
  193.             $this->enabled $enabled;
  194.             return $this;
  195.         }
  196.         public function getSlug(): ?string
  197.         {
  198.             return $this->slug;
  199.         }
  200.         public function setSlug( ?string $slug ): self
  201.         {
  202.             $this->slug $slug;
  203.             return $this;
  204.         }
  205.     }