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.     //
  58.     public function getId(): ?string
  59.     {
  60.         return $this->id;
  61.     }
  62.     public function getValue(): ?string
  63.     {
  64.         return $this->value;
  65.     }
  66.     public function setValue(string $value): self
  67.     {
  68.         $this->value $value;
  69.         return $this;
  70.     }
  71.     public function getSlug(): ?string
  72.     {
  73.         return $this->slug;
  74.     }
  75.     public function setSlug(string $slug): self
  76.     {
  77.         $this->slug $slug;
  78.         return $this;
  79.     }
  80.     /**
  81.      * @return Collection<int, User>
  82.      */
  83.     public function getUsers(): Collection
  84.     {
  85.         return $this->users;
  86.     }
  87.     public function addUser(User $user): self
  88.     {
  89.         if (!$this->users->contains($user)) {
  90.             $this->users->add($user);
  91.             $user->setAccountType($this);
  92.         }
  93.         return $this;
  94.     }
  95.     public function removeUser(User $user): self
  96.     {
  97.         if ($this->users->removeElement($user)) {
  98.             // set the owning side to null (unless already changed)
  99.             if ($user->getAccountType() === $this) {
  100.                 $user->setAccountType(null);
  101.             }
  102.         }
  103.         return $this;
  104.     }
  105.     /**
  106.      * @return Collection<int, JoinTableAccountTypePermission>
  107.      */
  108.     public function getPermissions(): Collection
  109.     {
  110.         return $this->permissions;
  111.     }
  112.     public function addPermission(JoinTableAccountTypePermission $permission): self
  113.     {
  114.         if (!$this->permissions->contains($permission)) {
  115.             $this->permissions->add($permission);
  116.             $permission->setAccountType($this);
  117.         }
  118.         return $this;
  119.     }
  120.     public function removePermission(JoinTableAccountTypePermission $permission): self
  121.     {
  122.         if ($this->permissions->removeElement($permission)) {
  123.             // set the owning side to null (unless already changed)
  124.             if ($permission->getAccountType() === $this) {
  125.                 $permission->setAccountType(null);
  126.             }
  127.         }
  128.         return $this;
  129.     }
  130.     public function getCategory(): ?AccountCategory
  131.     {
  132.         return $this->category;
  133.     }
  134.     public function setCategory(?AccountCategory $category): self
  135.     {
  136.         $this->category $category;
  137.         return $this;
  138.     }
  139. }