src/Entity/Account/Owner.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Account;
  3. use App\Entity\Entry\Entry;
  4. use App\Entity\Traits\ModifiedLifecycleTrait;
  5. use App\Entity\Traits\ModifiedTimeTrait;
  6. use App\Repository\Account\OwnerRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. /**
  11.  * @ORM\Entity(repositoryClass=OwnerRepository::class)
  12.  * @ORM\Table(name="account_owner")
  13.  * @ORM\HasLifecycleCallbacks()
  14.  */
  15. class Owner
  16. {
  17.     public function __toString(): string
  18.     {
  19.         return $this->companyName;
  20.     }
  21.     public const STATUS_ENABLE 1;
  22.     public const STATUS_DISABLE 2;
  23.     public const STATUS_COLD 3;
  24.     public const STATUS_ENABLE_STR "有効";
  25.     public const STATUS_DISABLE_STR "無効";
  26.     public const STATUS_COLD_STR "失効";
  27.     static public function getStatusArray(): array
  28.     {
  29.         return [
  30.             self::STATUS_ENABLE => self::STATUS_ENABLE_STR,
  31.             self::STATUS_DISABLE => self::STATUS_DISABLE_STR,
  32.             self::STATUS_COLD => self::STATUS_COLD_STR
  33.         ];
  34.     }
  35.     use ModifiedTimeTrait;
  36.     use ModifiedLifecycleTrait;
  37.     /**
  38.      * @ORM\Id
  39.      * @ORM\GeneratedValue
  40.      * @ORM\Column(type="integer")
  41.      */
  42.     private $id;
  43.     /**
  44.      * @ORM\OneToOne(targetEntity=Account::class, inversedBy="owner", cascade={"persist", "remove"})
  45.      * @ORM\JoinColumn(nullable=false)
  46.      */
  47.     private $Account;
  48.     /**
  49.      * @ORM\Column(type="string", length=64)
  50.      */
  51.     private $companyName;
  52.     /**
  53.      * @ORM\Column(type="string", length=128)
  54.      */
  55.     private $companyKana;
  56.     /**
  57.      * @ORM\Column(type="string", length=32)
  58.      */
  59.     private $representativeName;
  60.     /**
  61.      * @ORM\Column(type="string", length=48)
  62.      */
  63.     private $representativeKana;
  64.     /**
  65.      * @ORM\Column(type="string", length=32)
  66.      */
  67.     private $chargerName;
  68.     /**
  69.      * @ORM\Column(type="string", length=16)
  70.      */
  71.     private $phone;
  72.     /**
  73.      * @ORM\Column(type="integer")
  74.      */
  75.     private $status;
  76.     /**
  77.      * @ORM\OneToMany(targetEntity=Entry::class, mappedBy="Owner")
  78.      */
  79.     private $entries;
  80.     /**
  81.      * @ORM\Column(type="string", length=48, nullable=true)
  82.      */
  83.     private $managerName;
  84.     /**
  85.      * @ORM\Column(type="string", length=255)
  86.      */
  87.     private $address;
  88.     /**
  89.      * @ORM\Column(type="string", length=255)
  90.      */
  91.     private $url;
  92.     public function __construct()
  93.     {
  94.         $this->entries = new ArrayCollection();
  95.     }
  96.     public function getId(): ?int
  97.     {
  98.         return $this->id;
  99.     }
  100.     public function getAccount(): ?Account
  101.     {
  102.         return $this->Account;
  103.     }
  104.     public function setAccount(Account $Account): self
  105.     {
  106.         $this->Account $Account;
  107.         return $this;
  108.     }
  109.     public function getCompanyName(): ?string
  110.     {
  111.         return $this->companyName;
  112.     }
  113.     public function setCompanyName(string $companyName): self
  114.     {
  115.         $this->companyName $companyName;
  116.         return $this;
  117.     }
  118.     public function getCompanyKana(): ?string
  119.     {
  120.         return $this->companyKana;
  121.     }
  122.     public function setCompanyKana(string $companyKana): self
  123.     {
  124.         $this->companyKana $companyKana;
  125.         return $this;
  126.     }
  127.     public function getRepresentativeName(): ?string
  128.     {
  129.         return $this->representativeName;
  130.     }
  131.     public function setRepresentativeName(string $representativeName): self
  132.     {
  133.         $this->representativeName $representativeName;
  134.         return $this;
  135.     }
  136.     public function getRepresentativeKana(): ?string
  137.     {
  138.         return $this->representativeKana;
  139.     }
  140.     public function setRepresentativeKana(string $representativeKana): self
  141.     {
  142.         $this->representativeKana $representativeKana;
  143.         return $this;
  144.     }
  145.     public function getChargerName(): ?string
  146.     {
  147.         return $this->chargerName;
  148.     }
  149.     public function setChargerName(string $chargerName): self
  150.     {
  151.         $this->chargerName $chargerName;
  152.         return $this;
  153.     }
  154.     public function getPhone(): ?string
  155.     {
  156.         return $this->phone;
  157.     }
  158.     public function setPhone(string $phone): self
  159.     {
  160.         $this->phone $phone;
  161.         return $this;
  162.     }
  163.     public function getStatus(): int
  164.     {
  165.         return $this->status;
  166.     }
  167.     public function setStatus(int $status): self
  168.     {
  169.         $this->status $status;
  170.         return $this;
  171.     }
  172.     public function statusToString(): string
  173.     {
  174.         $choice self::getStatusArray();
  175.         if(!$this->status || !isset($choice[$this->status])) return "";
  176.         return $choice[$this->status];
  177.     }
  178.     /**
  179.      * @return Collection|Entry[]
  180.      */
  181.     public function getEntries(): Collection
  182.     {
  183.         return $this->entries;
  184.     }
  185.     public function addEntry(Entry $entry): self
  186.     {
  187.         if (!$this->entries->contains($entry)) {
  188.             $this->entries[] = $entry;
  189.             $entry->setOwner($this);
  190.         }
  191.         return $this;
  192.     }
  193.     public function removeEntry(Entry $entry): self
  194.     {
  195.         if ($this->entries->removeElement($entry)) {
  196.             // set the owning side to null (unless already changed)
  197.             if ($entry->getOwner() === $this) {
  198.                 $entry->setOwner(null);
  199.             }
  200.         }
  201.         return $this;
  202.     }
  203.     public function getManagerName(): ?string
  204.     {
  205.         return $this->managerName;
  206.     }
  207.     public function setManagerName(?string $managerName): self
  208.     {
  209.         $this->managerName $managerName;
  210.         return $this;
  211.     }
  212.     public function getAddress(): ?string
  213.     {
  214.         return $this->address;
  215.     }
  216.     public function setAddress(string $address): self
  217.     {
  218.         $this->address $address;
  219.         return $this;
  220.     }
  221.     public function getUrl(): ?string
  222.     {
  223.         return $this->url;
  224.     }
  225.     public function setUrl(string $url): self
  226.     {
  227.         $this->url $url;
  228.         return $this;
  229.     }
  230. }