src/Admin/Entity/StdRoles.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Admin\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * StdRoles
  8.  */
  9. #[ORM\Table(name'std_roles')]
  10. #[ORM\Index(name'fk_std_roles_std_users'columns: ['created_by'])]
  11. #[ORM\Index(name'fk_std_roles_std_users_0'columns: ['updated_by'])]
  12. #[ORM\Entity]
  13. class StdRoles /* implements \Serializable */
  14. {
  15.     /**
  16.      * @var int
  17.      */
  18.     #[ORM\Column(name'id'type'integer'nullablefalseoptions: ['unsigned' => true'comment' => 'Role unique identifier'])]
  19.     #[ORM\Id]
  20.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  21.     private $id;
  22.     /**
  23.      * @var string
  24.      */
  25.     #[ORM\Column(name'name'type'string'length100nullablefalseoptions: ['comment' => 'Role name'])]
  26.     private $name;
  27.     /**
  28.      * @var bool
  29.      */
  30.     #[ORM\Column(name'is_active'type'boolean'nullablefalseoptions: ['default' => 1'comment' => 'Flag that indicates if the role is active'])]
  31.     private $isActive '1';
  32.     /**
  33.      * @var \DateTime
  34.      */
  35.     #[ORM\Column(name'created_date'type'datetime'nullablefalseoptions: ['comment' => 'Date and time of the record creation'])]
  36.     private $createdDate;
  37.     /**
  38.      * @var \DateTime
  39.      */
  40.     #[ORM\Column(name'updated_date'type'datetime'nullablefalseoptions: ['comment' => 'Date and time the record was last updated'])]
  41.     private $updatedDate;
  42.     /**
  43.      * @var \App\Admin\Entity\StdUsers
  44.      */
  45.     #[ORM\JoinColumn(name'created_by'referencedColumnName'id')]
  46.     #[ORM\ManyToOne(targetEntity'App\Admin\Entity\StdUsers')]
  47.     private $createdBy;
  48.     /**
  49.      * @var \App\Admin\Entity\StdUsers
  50.      */
  51.     #[ORM\JoinColumn(name'updated_by'referencedColumnName'id')]
  52.     #[ORM\ManyToOne(targetEntity'App\Admin\Entity\StdUsers')]
  53.     private $updatedBy;
  54.     #[ORM\ManyToMany(targetEntityStdUsers::class, mappedBy'userRoles')]
  55.     private Collection $users;
  56.     #[ORM\OneToMany(mappedBy"role"targetEntityStdRolesPermissions::class)]
  57.     private Collection $optionsPermissions;
  58.     public function __construct()
  59.     {
  60.         $this->users = new ArrayCollection();
  61.         $this->optionsPermissions = new ArrayCollection();
  62.     }
  63.     public function getId(): ?int
  64.     {
  65.         return $this->id;
  66.     }
  67.     public function getName(): ?string
  68.     {
  69.         return $this->name;
  70.     }
  71.     public function setName(string $name): self
  72.     {
  73.         $this->name $name;
  74.         return $this;
  75.     }
  76.     public function getIsActive(): ?bool
  77.     {
  78.         return $this->isActive;
  79.     }
  80.     public function setIsActive(bool $isActive): self
  81.     {
  82.         $this->isActive $isActive;
  83.         return $this;
  84.     }
  85.     public function getCreatedDate(): ?\DateTimeInterface
  86.     {
  87.         return $this->createdDate;
  88.     }
  89.     public function setCreatedDate(\DateTimeInterface $createdDate): self
  90.     {
  91.         $this->createdDate $createdDate;
  92.         return $this;
  93.     }
  94.     public function getUpdatedDate(): ?\DateTimeInterface
  95.     {
  96.         return $this->updatedDate;
  97.     }
  98.     public function setUpdatedDate(\DateTimeInterface $updatedDate): self
  99.     {
  100.         $this->updatedDate $updatedDate;
  101.         return $this;
  102.     }
  103.     public function getCreatedBy(): ?\App\Admin\Entity\StdUsers
  104.     {
  105.         return $this->createdBy;
  106.     }
  107.     public function setCreatedBy(?StdUsers $createdBy): self
  108.     {
  109.         $this->createdBy $createdBy;
  110.         return $this;
  111.     }
  112.     public function getUpdatedBy(): ?\App\Admin\Entity\StdUsers
  113.     {
  114.         return $this->updatedBy;
  115.     }
  116.     public function setUpdatedBy(?StdUsers $updatedBy): self
  117.     {
  118.         $this->updatedBy $updatedBy;
  119.         return $this;
  120.     }
  121.      #[ORM\PreUpdate]
  122.     public function setUpdated()
  123.     {
  124.         $this->setUpdatedDate(new \DateTime());
  125.     }
  126.     #[ORM\PrePersist]
  127.     public function setCreated()
  128.     {
  129.         $this->setUpdatedDate(new \DateTime());
  130.         $this->setCreatedDate(new \DateTime());
  131.     }
  132.     /** Function serialize is here to solve "Notice: unserialize(): Error at offset" on php version 7.3 */
  133.     /*public function serialize()
  134.     {
  135.         list($major, $minor, $release) = explode(".", phpversion());
  136.         $vars = get_object_vars($this);
  137.         if ($major == 7 && $minor == 3)
  138.         {
  139.             unset($vars["createdBy"]);
  140.             unset($vars["updatedBy"]);
  141.         }
  142.         return serialize($vars);
  143.         //return serialize($this);
  144.     }*/
  145.     /** Function unserialize is here to solve "Notice: unserialize(): Error at offset" on php version 7.3 */
  146.     /*public function unserialize($data)
  147.     {
  148.         $vars = unserialize($data);
  149.         foreach ($vars as $key => $value)
  150.         {
  151.             $this->$key = $value;
  152.         }
  153.     }*/
  154.     /**
  155.      * @return Collection<int, StdUsers>
  156.      */
  157.     public function getUsers(): Collection
  158.     {
  159.         return $this->users;
  160.     }
  161.     public function addUser(StdUsers $user): static
  162.     {
  163.         if (!$this->users->contains($user)) {
  164.             $this->users->add($user);
  165.             $user->addRole($this);
  166.         }
  167.         return $this;
  168.     }
  169.     public function removeUser(StdUsers $user): static
  170.     {
  171.         if ($this->users->removeElement($user)) {
  172.             $user->removeRole($this);
  173.         }
  174.         return $this;
  175.     }
  176.     public function getOptionsPermissions(): Collection
  177.     {
  178.         return $this->optionsPermissions;
  179.     }
  180.     public function setOptionsPermissions(Collection $optionsPermissions): void
  181.     {
  182.         $this->optionsPermissions $optionsPermissions;
  183.     }
  184. }