src/Entity/Slave/AccountType.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Slave;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Table(name="eposm_s_account_type")
  9.  * @ORM\Entity(repositoryClass="App\Repository\Slave\AccountTypeRepository")
  10.  */
  11. class AccountType
  12. {
  13.     public function __toString(){
  14.         return $this->getValue();
  15.     }
  16.     public function getCanDelete(){
  17.         if(sizeof($this->users) > 0) return false;
  18.         return true;
  19.     }
  20.     
  21.     /**
  22.      * @ORM\Column(name="id", type="bigint")
  23.      * @ORM\Id
  24.      * @ORM\GeneratedValue(strategy="AUTO")
  25.      */
  26.     protected $id;
  27.     /**
  28.      * @ORM\Column(name="value", type="string", length=191)
  29.      */
  30.     protected $value;
  31.     /**
  32.      * @ORM\Column(name="slug", type="string", length=191)
  33.      */
  34.     protected $slug;
  35.     // OneToMany
  36.         /**
  37.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\User", mappedBy="accountType")
  38.          */
  39.         private $users;
  40.         
  41.         /**
  42.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\JoinTableAccountTypePermission", mappedBy="accountType")
  43.          */
  44.         private $permissions;
  45.     //
  46.     // ManyToOne
  47.         /**
  48.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\AccountCategory", inversedBy="types")
  49.          * @ORM\JoinColumn(name="category_id", referencedColumnName="id")
  50.          */
  51.         private $category;
  52.         public function __construct()
  53.         {
  54.             $this->users = new ArrayCollection();
  55.             $this->permissions = new ArrayCollection();
  56.         }
  57.         public function getId(): ?string
  58.         {
  59.             return $this->id;
  60.         }
  61.         public function getValue(): ?string
  62.         {
  63.             return $this->value;
  64.         }
  65.         public function setValue(string $value): static
  66.         {
  67.             $this->value $value;
  68.             return $this;
  69.         }
  70.         public function getSlug(): ?string
  71.         {
  72.             return $this->slug;
  73.         }
  74.         public function setSlug(string $slug): static
  75.         {
  76.             $this->slug $slug;
  77.             return $this;
  78.         }
  79.         /**
  80.          * @return Collection<int, User>
  81.          */
  82.         public function getUsers(): Collection
  83.         {
  84.             return $this->users;
  85.         }
  86.         public function addUser(User $user): static
  87.         {
  88.             if (!$this->users->contains($user)) {
  89.                 $this->users->add($user);
  90.                 $user->setAccountType($this);
  91.             }
  92.             return $this;
  93.         }
  94.         public function removeUser(User $user): static
  95.         {
  96.             if ($this->users->removeElement($user)) {
  97.                 // set the owning side to null (unless already changed)
  98.                 if ($user->getAccountType() === $this) {
  99.                     $user->setAccountType(null);
  100.                 }
  101.             }
  102.             return $this;
  103.         }
  104.         /**
  105.          * @return Collection<int, JoinTableAccountTypePermission>
  106.          */
  107.         public function getPermissions(): Collection
  108.         {
  109.             return $this->permissions;
  110.         }
  111.         public function addPermission(JoinTableAccountTypePermission $permission): static
  112.         {
  113.             if (!$this->permissions->contains($permission)) {
  114.                 $this->permissions->add($permission);
  115.                 $permission->setAccountType($this);
  116.             }
  117.             return $this;
  118.         }
  119.         public function removePermission(JoinTableAccountTypePermission $permission): static
  120.         {
  121.             if ($this->permissions->removeElement($permission)) {
  122.                 // set the owning side to null (unless already changed)
  123.                 if ($permission->getAccountType() === $this) {
  124.                     $permission->setAccountType(null);
  125.                 }
  126.             }
  127.             return $this;
  128.         }
  129.         public function getCategory(): ?AccountCategory
  130.         {
  131.             return $this->category;
  132.         }
  133.         public function setCategory(?AccountCategory $category): static
  134.         {
  135.             $this->category $category;
  136.             return $this;
  137.         }
  138. }