src/Entity/Properties/Image.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Properties;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Symfony\Component\Validator\Constraints AS Assert;
  5. use Doctrine\ORM\Mapping AS ORM;
  6. use Ramsey\Uuid\Uuid;
  7. use Ramsey\Uuid\Lazy\LazyUuidFromString;
  8. use App\Entity\BaseEntity;
  9. /**
  10.  * @ORM\Entity(repositoryClass="App\Repository\Properties\ImageRepository")
  11.  * @ORM\Table(name="properties_image")
  12.  * @ORM\HasLifecycleCallbacks()
  13.  */
  14. class Image extends BaseEntity
  15. {
  16.     /**
  17.     * @ORM\Id
  18.     * @ORM\GeneratedValue(strategy="AUTO")
  19.     * @ORM\Column(type="integer")
  20.     */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="uuid")
  24.      * @Assert\Uuid
  25.      */
  26.     protected $uuid;
  27.     /**
  28.      * @var \DateTime
  29.      *
  30.      * @ORM\Column(type="datetime", nullable=false)
  31.      * @Assert\Type("\DateTime")
  32.      */
  33.     private $created;
  34.     /**
  35.      * @ORM\Column(type="string", length=128, nullable=false)
  36.      * @Assert\NotBlank()
  37.      */
  38.     private $filename;
  39.     /**
  40.      * @var \DateTime
  41.      *
  42.      * @ORM\Column(type="bigint", length=14, nullable=false, unique=true)
  43.      * @Assert\NotBlank
  44.      */
  45.     private $displayOrder;
  46.     /**
  47.      * @ORM\ManyToOne(targetEntity=Property::class, inversedBy="images")
  48.      * @ORM\JoinColumn(nullable=true)
  49.      **/
  50.     private $property;
  51.     public function __construct(array $defaults = array())
  52.     {
  53.         // Defaults
  54.         $this->setUuid(Uuid::uuid4());
  55.         $this->setCreated(new \DateTime());
  56.         $this->setDisplayOrder(number_format(microtime(true), 4''''));
  57.         parent::__construct($defaults);
  58.     }
  59.     public function __toString()
  60.     {
  61.         return $this->getId();
  62.     }
  63.     public function getId(): ?int
  64.     {
  65.         return $this->id;
  66.     }
  67.     public function getUuid(): LazyUuidFromString
  68.     {
  69.         return $this->uuid;
  70.     }
  71.     public function setUuid(LazyUuidFromString $uuid): void
  72.     {
  73.         $this->uuid $uuid;
  74.     }
  75.     public function setCreated(\DateTime $created): void
  76.     {
  77.         $this->created $created;
  78.     }
  79.     public function getCreated(): \DateTime
  80.     {
  81.         return $this->created;
  82.     }
  83.     public function getFilename(): string
  84.     {
  85.         return $this->filename;
  86.     }
  87.     public function setFilename(string $filename): void
  88.     {
  89.         $this->filename $filename;
  90.     }
  91.     public function getDisplayOrder()
  92.     {
  93.         return $this->displayOrder;
  94.     }
  95.     public function setDisplayOrder(int $displayOrder)
  96.     {
  97.         $this->displayOrder $displayOrder;
  98.     }
  99.     public function getProperty()
  100.     {
  101.         return $this->property;
  102.     }
  103.     public function setProperty(Property $property null)
  104.     {
  105.         $this->property $property;
  106.     }
  107. }