src/Entity/Users/Group.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Users;
  3. use App\Entity\BaseEntity;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Symfony\Component\Validator\Constraints AS Constraints;
  6. use Symfony\Component\Validator\Constraints AS Assert;
  7. use Doctrine\ORM\Mapping AS ORM;
  8. use Ramsey\Uuid\Uuid;
  9. /**
  10.  * @ORM\Entity(repositoryClass="App\Repository\Users\GroupRepository")
  11.  * @ORM\Table(name="users_group")
  12.  * @ORM\HasLifecycleCallbacks()
  13.  */
  14. class Group 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\NotBlank
  32.      */
  33.     private $created;
  34.      /**
  35.      * @ORM\Column(type="string", length=30, nullable=true)
  36.      */
  37.     private $name;
  38.      /**
  39.      * @ORM\OneToMany(targetEntity=User::class, mappedBy="group")
  40.      * @ORM\JoinColumn(nullable=false)
  41.      **/
  42.     private $users;
  43.     public function __construct()
  44.     {
  45.         // Generate UUID
  46.         $uuid Uuid::uuid1();
  47.         $this->setUuid($uuid->toString());
  48.         // Defaults
  49.         $this->created = new \DateTime();
  50.     }
  51.     public function __toString() 
  52.     {
  53.         return $this->getName();
  54.     }
  55.     /**
  56.      * Get Id
  57.      */ 
  58.     public function getId()
  59.     {
  60.         return $this->id;
  61.     }
  62.     /**
  63.      * Set Id
  64.      *
  65.      * @return  self
  66.      */ 
  67.     public function setId($id)
  68.     {
  69.         $this->id $id;
  70.         return $this;
  71.     }
  72.     /**
  73.      * Get the value of uuid
  74.      */ 
  75.     public function getUuid()
  76.     {
  77.         return $this->uuid;
  78.     }
  79.     /**
  80.      * Set the value of uuid
  81.      *
  82.      * @return  self
  83.      */ 
  84.     public function setUuid($uuid)
  85.     {
  86.         $this->uuid $uuid;
  87.         return $this;
  88.     }
  89.     /**
  90.      * Get the value of name
  91.      */ 
  92.     public function getName()
  93.     {
  94.         return $this->name;
  95.     }
  96.     /**
  97.      * Set the value of name
  98.      *
  99.      * @return  self
  100.      */ 
  101.     public function setName($name)
  102.     {
  103.         $this->name $name;
  104.         return $this;
  105.     }
  106.     /**
  107.      * Get the value of created
  108.      *
  109.      * @return  \DateTime
  110.      */ 
  111.     public function getCreated()
  112.     {
  113.         return $this->created;
  114.     }
  115.     /**
  116.      * Set the value of created
  117.      *
  118.      * @param  \DateTime  $created
  119.      *
  120.      * @return  self
  121.      */ 
  122.     public function setCreated(\DateTime $created)
  123.     {
  124.         $this->created $created;
  125.         return $this;
  126.     }
  127. }