src/Entity/Properties/Feature.php line 17

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. use App\Entity\Properties\PropertyFeature;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\Repository\Properties\FeatureRepository")
  12.  * @ORM\Table(name="properties_feature")
  13.  * @ORM\HasLifecycleCallbacks()
  14.  */
  15. class Feature extends BaseEntity
  16. {
  17.     /**
  18.     * @ORM\Id
  19.     * @ORM\GeneratedValue(strategy="AUTO")
  20.     * @ORM\Column(type="integer")
  21.     */
  22.     private $id;
  23.     /**
  24.      * @ORM\Column(type="uuid")
  25.      * @Assert\Uuid
  26.      */
  27.     protected $uuid;
  28.     /**
  29.      * @var \DateTime
  30.      *
  31.      * @ORM\Column(type="datetime", nullable=false)
  32.      * @Assert\Type("\DateTime")
  33.      */
  34.     private $created;
  35.     /**
  36.      * @ORM\Column(type="string", length=128, nullable=false)
  37.      * @Assert\NotBlank()
  38.      */
  39.     private $name;
  40.     /**
  41.      * @ORM\OneToMany(targetEntity=PropertyFeature::class, mappedBy="feature", cascade={"all"})
  42.      **/
  43.     private $propertyFeatures;
  44.     public function __construct(array $defaults = array())
  45.     {
  46.         // Defaults
  47.         $this->setUuid(Uuid::uuid4());
  48.         $this->setCreated(new \DateTime());
  49.         $this->propertyFeatures = new ArrayCollection();
  50.         parent::__construct($defaults);
  51.     }
  52.     public function __toString()
  53.     {
  54.         return $this->getName();
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getUuid(): LazyUuidFromString
  61.     {
  62.         return $this->uuid;
  63.     }
  64.     public function setUuid(LazyUuidFromString $uuid): void
  65.     {
  66.         $this->uuid $uuid;
  67.     }
  68.     public function setCreated(\DateTime $created): void
  69.     {
  70.         $this->created $created;
  71.     }
  72.     public function getCreated(): \DateTime
  73.     {
  74.         return $this->created;
  75.     }
  76.     public function getName(): string
  77.     {
  78.         return $this->name;
  79.     }
  80.     public function setName(string $name): void
  81.     {
  82.         $this->name $name;
  83.     }
  84. }