src/Entity/Organization.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  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\Entity(repositoryClass="App\Repository\OrganizationRepository")
  9.  * @ORM\Table(indexes={              
  10.  *   @ORM\Index(name="description",columns={"description"}),
  11.  *   @ORM\Index(name="name",columns={"name"}),
  12.  *   @ORM\Index(name="createdAt",columns={"created_at"}),
  13.  *   @ORM\Index(name="updatedAt",columns={"updated_at"}),
  14.  *   @ORM\Index(name="deletedAt",columns={"deleted_at"}),
  15.  *   @ORM\Index(name="created",columns={"created"}),
  16.  *  })
  17.  * @ORM\HasLifecycleCallbacks
  18.  */
  19. class Organization {
  20.     const TYPE_COMPANY 'TYPE_COMPANY';
  21.     const TYPE_ENTITY 'TYPE_ENTITY';
  22.     /*List Type*/
  23.     const TYPE_BLACK_LIST 'TYPE_BLACK_LIST';
  24.     /**
  25.      * @ORM\Id()
  26.      * @ORM\GeneratedValue()
  27.      * @ORM\Column(type="integer")
  28.      */
  29.     private $id;
  30.     /**
  31.      * @ORM\Column(type="string", length=255)
  32.      */
  33.     private $name;
  34.     /**
  35.      * @ORM\Column(type="string", length=255)
  36.      */
  37.     private $type;
  38.     /**
  39.      * @ORM\Column(type="string", length=255, nullable=true)
  40.      */
  41.     private $description;
  42.     /**
  43.      * @ORM\Column(type="text",  nullable=true)
  44.      */
  45.     private $logo;
  46.     /**
  47.      * @ORM\ManyToOne(targetEntity="UserType")
  48.      * @ORM\JoinColumn(name="user_type_id", referencedColumnName="id",nullable=true)
  49.      */
  50.     protected $userType;
  51.     /**
  52.      * @ORM\OneToMany(targetEntity="User", mappedBy="organization")
  53.      */
  54.     private $users;
  55.     /**
  56.      * @ORM\OneToMany(targetEntity="Animal", mappedBy="organization")
  57.      */
  58.     private $animals;
  59.     /**
  60.      * @ORM\Column(type="datetime", nullable=true)
  61.      */
  62.     private $created;
  63.     
  64.      /**
  65.      * @ORM\Column(type="string", length=255, nullable=true)
  66.      */
  67.     private $cuit;
  68.     
  69.     /**
  70.      * @ORM\Column(type="string", length=255, nullable=true)
  71.      */
  72.     private $email;
  73.     /**
  74.      * @ORM\Column(type="string", nullable=true)
  75.      */
  76.     private $phone;
  77.     /**
  78.      * @ORM\Column(type="string", length=255, nullable=true)
  79.      */
  80.     private $businessName;
  81.      /**
  82.      * @ORM\ManyToOne(targetEntity="Address", cascade={"persist"})
  83.      * @ORM\JoinColumn(name="address_id", referencedColumnName="id")
  84.      */
  85.     private $address;
  86.     /**
  87.      * @ORM\Column(type="string", length=255,  nullable=true)
  88.      */
  89.     private $listType;
  90.     /**
  91.      * @ORM\Column(type="string", length=255, nullable=true)
  92.      */
  93.     private $activity;
  94.     /**
  95.      * @ORM\Column(type="datetime")
  96.      */
  97.     private $createdAt;
  98.     /**
  99.      * @ORM\Column(type="datetime")
  100.      */
  101.     private $updatedAt;
  102.     /**
  103.      * @ORM\Column(type="datetime", nullable=true)
  104.      */
  105.     private $deletedAt;
  106.     /**
  107.      * @ORM\Column(type="boolean", nullable=true)
  108.      */
  109.     private $isProducer;
  110.      /** @ORM\PreUpdate */
  111.     public function PreUpdate()
  112.     {
  113.         $this->setUpdatedAt( new \DateTime() );
  114.     }
  115.     /** @ORM\PrePersist */
  116.     public function PrePersist()
  117.     {
  118.         $this->setCreatedAt( new \DateTime() );
  119.         $this->setUpdatedAt( new \DateTime() );
  120.     }
  121.     public function __toString() {
  122.                  return $this->name;
  123.              }
  124.     public function __construct() {
  125.         $this->created = new \DateTime('now');
  126.         $this->users = new ArrayCollection();
  127.         $this->animals = new ArrayCollection();
  128.         $this->setType(Organization::TYPE_COMPANY);
  129.     }
  130.     public function getId(): ?int {
  131.         return $this->id;
  132.     }
  133.     public function setId($id) {
  134.         $this->id $id;
  135.     }
  136.     public function getName(): ?string {
  137.         return $this->name;
  138.     }
  139.     public function setName(string $name): self {
  140.         $this->name $name;
  141.         return $this;
  142.     }
  143.     public function getDescription(): ?string {
  144.         return $this->description;
  145.     }
  146.     public function setDescription(?string $description): self {
  147.         $this->description $description;
  148.         return $this;
  149.     }
  150.     public function getCreated(): ?\DateTimeInterface {
  151.         return $this->created;
  152.     }
  153.     public function setCreated(\DateTimeInterface $created): self {
  154.         $this->created $created;
  155.         return $this;
  156.     }
  157.     public function getType(): ?string {
  158.         return $this->type;
  159.     }
  160.     public function setType(string $type): self {
  161.         $this->type $type;
  162.         return $this;
  163.     }
  164.     /**
  165.      * @return Collection|User[]
  166.      */
  167.     public function getUsers(): Collection {
  168.         return $this->users;
  169.     }
  170.     public function addUser(User $user): self {
  171.         if (!$this->users->contains($user)) {
  172.             $this->users[] = $user;
  173.             $user->setOrganization($this);
  174.         }
  175.         return $this;
  176.     }
  177.     public function removeUser(User $user): self {
  178.         if ($this->users->contains($user)) {
  179.             $this->users->removeElement($user);
  180.             // set the owning side to null (unless already changed)
  181.             if ($user->getOrganization() === $this) {
  182.                 $user->setOrganization(null);
  183.             }
  184.         }
  185.         return $this;
  186.     }
  187.     /**
  188.      * @return Collection|Animal[]
  189.      */
  190.     public function getAnimals(): Collection {
  191.         return $this->animals;
  192.     }
  193.     public function addAnimal(Animal $animal): self {
  194.         if (!$this->animals->contains($animal)) {
  195.             $this->animals[] = $animal;
  196.             $animal->setOrganization($this);
  197.         }
  198.         return $this;
  199.     }
  200.     public function removeAnimal(Animal $animal): self {
  201.         if ($this->animals->contains($animal)) {
  202.             $this->animals->removeElement($animal);
  203.             // set the owning side to null (unless already changed)
  204.             if ($animal->getOrganization() === $this) {
  205.                 $animal->setOrganization(null);
  206.             }
  207.         }
  208.         return $this;
  209.     }
  210.     public function getLogo(): ?string {
  211.         return $this->logo;
  212.     }
  213.     public function setLogo(?string $logo): self {
  214.         $this->logo $logo;
  215.         return $this;
  216.     }
  217.     /**
  218.      * @return mixed
  219.      */
  220.     public function getUserType() {
  221.         return $this->userType;
  222.     }
  223.     /**
  224.      * @param mixed $userType
  225.      */
  226.     public function setUserType($userType): void {
  227.         $this->userType $userType;
  228.     }
  229. /**
  230.      * @return mixed
  231.      */
  232.     public function getCuit()
  233.     {
  234.         return $this->cuit;
  235.     }
  236.     /**
  237.      * @param mixed $cuit
  238.      */
  239.     public function setCuit($cuit)
  240.     {
  241.         $this->cuit $cuit;
  242.     }
  243.     
  244.      /**
  245.      * @return mixed
  246.      */
  247.     public function getEmail()
  248.     {
  249.         return $this->email;
  250.     }
  251.     /**
  252.      * @param mixed $email
  253.      */
  254.     public function setEmail($email)
  255.     {
  256.         $this->email $email;
  257.     }
  258.   /**
  259.      * @return mixed
  260.      */
  261.     public function getPhone()
  262.     {
  263.         return $this->phone;
  264.     }
  265.     /**
  266.      * @param mixed $phone
  267.      */
  268.     public function setPhone($phone)
  269.     {
  270.         $this->phone $phone;
  271.     }
  272.     
  273.     /**
  274.      * @return mixed
  275.      */
  276.     public function getBusinessName()
  277.     {
  278.         return $this->businessName;
  279.     }
  280.     /**
  281.      * @param mixed $businessName
  282.      */
  283.     public function setBusinessName($businessName): void
  284.     {
  285.         $this->businessName $businessName;
  286.     }
  287.  /**
  288.      * @return mixed
  289.      */
  290.     public function getAddress()
  291.     {
  292.         return $this->address;
  293.     }
  294.     /**
  295.      * @param mixed $address
  296.      */
  297.     public function setAddress($address): void
  298.     {
  299.         $this->address $address;
  300.     }
  301.     public function getListType(): ?string
  302.     {
  303.         return $this->listType;
  304.     }
  305.     public function setListType(string $listType): self
  306.     {
  307.         $this->listType $listType;
  308.         return $this;
  309.     }
  310.     public function getActivity(): ?string
  311.     {
  312.         return $this->activity;
  313.     }
  314.     public function setActivity(?string $activity): self
  315.     {
  316.         $this->activity $activity;
  317.         return $this;
  318.     }
  319.      public function getCreatedAt(): ?\DateTime
  320.     {
  321.         return $this->createdAt;
  322.     }
  323.     public function setCreatedAt(\DateTime $createdAt): self
  324.     {
  325.         $this->createdAt $createdAt;
  326.         return $this;
  327.     }
  328.     public function getUpdatedAt(): ?\DateTime
  329.     {
  330.         return $this->updatedAt;
  331.     }
  332.     public function setUpdatedAt(\DateTime $updatedAt): self
  333.     {
  334.         $this->updatedAt $updatedAt;
  335.         return $this;
  336.     }
  337.     public function getDeletedAt(): ?\DateTime
  338.     {
  339.         return $this->deletedAt;
  340.     }
  341.     public function setDeletedAt(?\DateTime $deletedAt): self
  342.     {
  343.         $this->deletedAt $deletedAt;
  344.         return $this;
  345.     }
  346.     public function isIsProducer(): ?bool
  347.     {
  348.         return $this->isProducer;
  349.     }
  350.     public function setIsProducer(bool $isProducer): self
  351.     {
  352.         $this->isProducer $isProducer;
  353.         return $this;
  354.     }
  355. }