<?php
namespace App\Entity\Slave;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="eposm_s_account_type")
* @ORM\Entity(repositoryClass="App\Repository\Slave\AccountTypeRepository")
*/
class AccountType
{
public function __toString(){
return $this->getValue();
}
public function getCanDelete(){
if(sizeof($this->users) > 0) return false;
return true;
}
/**
* @ORM\Column(name="id", type="bigint")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="value", type="string", length=191)
*/
protected $value;
/**
* @ORM\Column(name="slug", type="string", length=191)
*/
protected $slug;
// OneToMany
/**
* @ORM\OneToMany(targetEntity="App\Entity\Slave\User", mappedBy="accountType")
*/
private $users;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Slave\JoinTableAccountTypePermission", mappedBy="accountType")
*/
private $permissions;
//
// ManyToOne
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Slave\AccountCategory", inversedBy="types")
* @ORM\JoinColumn(name="category_id", referencedColumnName="id")
*/
private $category;
public function __construct()
{
$this->users = new ArrayCollection();
$this->permissions = new ArrayCollection();
}
//
public function getId(): ?string
{
return $this->id;
}
public function getValue(): ?string
{
return $this->value;
}
public function setValue(string $value): self
{
$this->value = $value;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
/**
* @return Collection<int, User>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users->add($user);
$user->setAccountType($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->removeElement($user)) {
// set the owning side to null (unless already changed)
if ($user->getAccountType() === $this) {
$user->setAccountType(null);
}
}
return $this;
}
/**
* @return Collection<int, JoinTableAccountTypePermission>
*/
public function getPermissions(): Collection
{
return $this->permissions;
}
public function addPermission(JoinTableAccountTypePermission $permission): self
{
if (!$this->permissions->contains($permission)) {
$this->permissions->add($permission);
$permission->setAccountType($this);
}
return $this;
}
public function removePermission(JoinTableAccountTypePermission $permission): self
{
if ($this->permissions->removeElement($permission)) {
// set the owning side to null (unless already changed)
if ($permission->getAccountType() === $this) {
$permission->setAccountType(null);
}
}
return $this;
}
public function getCategory(): ?AccountCategory
{
return $this->category;
}
public function setCategory(?AccountCategory $category): self
{
$this->category = $category;
return $this;
}
}