vendor/novosga/core/Entity/Servico.php line 228

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Novo SGA project.
  4.  *
  5.  * (c) Rogerio Lino <rogeriolino@gmail.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Novosga\Entity;
  11. /**
  12.  * Servico
  13.  *
  14.  * @author Rogerio Lino <rogeriolino@gmail.com>
  15.  */
  16. class Servico implements \JsonSerializable
  17. {
  18.     const SERVICO_CONSULTA 1;
  19.     const SERVICO_RETORNO 2;
  20.     const SERVICO_RECEPCAO 3;
  21.     /**
  22.      * @var mixed
  23.      */
  24.     protected $id;
  25.     
  26.     /**
  27.      * @var string
  28.      */
  29.     private $nome;
  30.     /**
  31.      * @var string
  32.      */
  33.     private $descricao;
  34.     /**
  35.      * @var int
  36.      */
  37.     private $ativo;
  38.     /**
  39.      * @var int
  40.      */
  41.     private $peso;
  42.     /**
  43.      * @var Servico
  44.      */
  45.     private $mestre;
  46.     /**
  47.      * @var Servico[]
  48.      */
  49.     private $subServicos;
  50.     /**
  51.      * @var ServicoUnidade[]
  52.      */
  53.     private $servicosUnidade;
  54.     /**
  55.      * @var \DateTime
  56.      */
  57.     private $createdAt;
  58.     /**
  59.      * @var \DateTime
  60.      */
  61.     private $updatedAt;
  62.     /**
  63.      * @var \DateTime
  64.      */
  65.     private $deletedAt;
  66.     public function __construct()
  67.     {
  68.         $this->ativo true;
  69.         $this->subServicos = new \Doctrine\Common\Collections\ArrayCollection();
  70.         $this->servicosUnidade = new \Doctrine\Common\Collections\ArrayCollection();
  71.     }
  72.     
  73.     public function getId()
  74.     {
  75.         return $this->id;
  76.     }
  77.     public function setId($id): self
  78.     {
  79.         $this->id $id;
  80.         
  81.         return $this;
  82.     }
  83.     public function setNome($nome): self
  84.     {
  85.         $this->nome $nome;
  86.         return $this;
  87.     }
  88.     public function getNome()
  89.     {
  90.         return $this->nome;
  91.     }
  92.     public function setDescricao($descricao): self
  93.     {
  94.         $this->descricao $descricao;
  95.         return $this;
  96.     }
  97.     public function getDescricao()
  98.     {
  99.         return $this->descricao;
  100.     }
  101.     public function setMestre(?Servico $servico): self
  102.     {
  103.         $this->mestre $servico;
  104.         return $this;
  105.     }
  106.     public function getMestre()
  107.     {
  108.         return $this->mestre;
  109.     }
  110.     public function isMestre()
  111.     {
  112.         return ($this->getId() && !$this->getMestre());
  113.     }
  114.     public function setAtivo(bool $ativo): self
  115.     {
  116.         $this->ativo $ativo;
  117.         return $this;
  118.     }
  119.     public function isAtivo(): bool
  120.     {
  121.         return $this->ativo;
  122.     }
  123.     public function getPeso()
  124.     {
  125.         return $this->peso;
  126.     }
  127.     public function setPeso($peso): self
  128.     {
  129.         $this->peso $peso;
  130.         return $this;
  131.     }
  132.     public function getSubServicos()
  133.     {
  134.         return $this->subServicos;
  135.     }
  136.     public function setSubServicos($subServicos): self
  137.     {
  138.         $this->subServicos $subServicos;
  139.         return $this;
  140.     }
  141.     public function getServicosUnidade()
  142.     {
  143.         return $this->servicosUnidade;
  144.     }
  145.     public function setServicosUnidade(array $servicosUnidade): self
  146.     {
  147.         $this->servicosUnidade $servicosUnidade;
  148.         return $this;
  149.     }
  150.     
  151.     public function getCreatedAt()
  152.     {
  153.         return $this->createdAt;
  154.     }
  155.     public function getUpdatedAt()
  156.     {
  157.         return $this->updatedAt;
  158.     }
  159.     public function getDeletedAt()
  160.     {
  161.         return $this->deletedAt;
  162.     }
  163.     public function setCreatedAt(\DateTime $createdAt): self
  164.     {
  165.         $this->createdAt $createdAt;
  166.         return $this;
  167.     }
  168.     public function setUpdatedAt(\DateTime $updatedAt): self
  169.     {
  170.         $this->updatedAt $updatedAt;
  171.         return $this;
  172.     }
  173.     public function setDeletedAt(\DateTime $deletedAt): self
  174.     {
  175.         $this->deletedAt $deletedAt;
  176.         
  177.         return $this;
  178.     }
  179.     
  180.     public function __toString()
  181.     {
  182.         return $this->nome;
  183.     }
  184.     public function jsonSerialize()
  185.     {
  186.         return [
  187.             'id'        => $this->getId(),
  188.             'nome'      => $this->getNome(),
  189.             'descricao' => $this->getDescricao(),
  190.             'peso'      => $this->getPeso(),
  191.             'ativo'     => $this->isAtivo(),
  192.             'macro'     => $this->getMestre(),
  193.             'createdAt' => $this->getCreatedAt() ? $this->getCreatedAt()->format('Y-m-d\TH:i:s') : null,
  194.             'updatedAt' => $this->getUpdatedAt() ? $this->getUpdatedAt()->format('Y-m-d\TH:i:s') : null,
  195.             'deletedAt' => $this->getDeletedAt() ? $this->getDeletedAt()->format('Y-m-d\TH:i:s') : null,
  196.         ];
  197.     }
  198. }