<?php
namespace App\Admin\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* StdRoles
*/
#[ORM\Table(name: 'std_roles')]
#[ORM\Index(name: 'fk_std_roles_std_users', columns: ['created_by'])]
#[ORM\Index(name: 'fk_std_roles_std_users_0', columns: ['updated_by'])]
#[ORM\Entity]
class StdRoles /* implements \Serializable */
{
/**
* @var int
*/
#[ORM\Column(name: 'id', type: 'integer', nullable: false, options: ['unsigned' => true, 'comment' => 'Role unique identifier'])]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
private $id;
/**
* @var string
*/
#[ORM\Column(name: 'name', type: 'string', length: 100, nullable: false, options: ['comment' => 'Role name'])]
private $name;
/**
* @var bool
*/
#[ORM\Column(name: 'is_active', type: 'boolean', nullable: false, options: ['default' => 1, 'comment' => 'Flag that indicates if the role is active'])]
private $isActive = '1';
/**
* @var \DateTime
*/
#[ORM\Column(name: 'created_date', type: 'datetime', nullable: false, options: ['comment' => 'Date and time of the record creation'])]
private $createdDate;
/**
* @var \DateTime
*/
#[ORM\Column(name: 'updated_date', type: 'datetime', nullable: false, options: ['comment' => 'Date and time the record was last updated'])]
private $updatedDate;
/**
* @var \App\Admin\Entity\StdUsers
*/
#[ORM\JoinColumn(name: 'created_by', referencedColumnName: 'id')]
#[ORM\ManyToOne(targetEntity: 'App\Admin\Entity\StdUsers')]
private $createdBy;
/**
* @var \App\Admin\Entity\StdUsers
*/
#[ORM\JoinColumn(name: 'updated_by', referencedColumnName: 'id')]
#[ORM\ManyToOne(targetEntity: 'App\Admin\Entity\StdUsers')]
private $updatedBy;
#[ORM\ManyToMany(targetEntity: StdUsers::class, mappedBy: 'userRoles')]
private Collection $users;
#[ORM\OneToMany(mappedBy: "role", targetEntity: StdRolesPermissions::class)]
private Collection $optionsPermissions;
public function __construct()
{
$this->users = new ArrayCollection();
$this->optionsPermissions = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
public function getCreatedDate(): ?\DateTimeInterface
{
return $this->createdDate;
}
public function setCreatedDate(\DateTimeInterface $createdDate): self
{
$this->createdDate = $createdDate;
return $this;
}
public function getUpdatedDate(): ?\DateTimeInterface
{
return $this->updatedDate;
}
public function setUpdatedDate(\DateTimeInterface $updatedDate): self
{
$this->updatedDate = $updatedDate;
return $this;
}
public function getCreatedBy(): ?\App\Admin\Entity\StdUsers
{
return $this->createdBy;
}
public function setCreatedBy(?StdUsers $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
public function getUpdatedBy(): ?\App\Admin\Entity\StdUsers
{
return $this->updatedBy;
}
public function setUpdatedBy(?StdUsers $updatedBy): self
{
$this->updatedBy = $updatedBy;
return $this;
}
#[ORM\PreUpdate]
public function setUpdated()
{
$this->setUpdatedDate(new \DateTime());
}
#[ORM\PrePersist]
public function setCreated()
{
$this->setUpdatedDate(new \DateTime());
$this->setCreatedDate(new \DateTime());
}
/** Function serialize is here to solve "Notice: unserialize(): Error at offset" on php version 7.3 */
/*public function serialize()
{
list($major, $minor, $release) = explode(".", phpversion());
$vars = get_object_vars($this);
if ($major == 7 && $minor == 3)
{
unset($vars["createdBy"]);
unset($vars["updatedBy"]);
}
return serialize($vars);
//return serialize($this);
}*/
/** Function unserialize is here to solve "Notice: unserialize(): Error at offset" on php version 7.3 */
/*public function unserialize($data)
{
$vars = unserialize($data);
foreach ($vars as $key => $value)
{
$this->$key = $value;
}
}*/
/**
* @return Collection<int, StdUsers>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(StdUsers $user): static
{
if (!$this->users->contains($user)) {
$this->users->add($user);
$user->addRole($this);
}
return $this;
}
public function removeUser(StdUsers $user): static
{
if ($this->users->removeElement($user)) {
$user->removeRole($this);
}
return $this;
}
public function getOptionsPermissions(): Collection
{
return $this->optionsPermissions;
}
public function setOptionsPermissions(Collection $optionsPermissions): void
{
$this->optionsPermissions = $optionsPermissions;
}
}