src/Entity/Unit.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UnitRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  6. #[UniqueEntity(fields: "code", message: "Ya existe una sucursal registrada con este código")]
  7. #[ORM\Entity(repositoryClass: UnitRepository::class)]
  8. #[ORM\Table(name: '`unit`')]
  9. class Unit
  10. {
  11. #[ORM\Id]
  12. #[ORM\GeneratedValue(strategy:"AUTO")]
  13. #[ORM\Column(type: "integer")]
  14. protected ?int $id = null;
  15. #[ORM\Column(type: "boolean")]
  16. protected $enabled = true;
  17. #[ORM\Column(type: "string")]
  18. protected $name;
  19. #[ORM\Column(type: "string")]
  20. protected $code;
  21. #[ORM\Column(type: "string")]
  22. protected $costCenter;
  23. #[ORM\ManyToOne(targetEntity:"App\Entity\City")]
  24. #[ORM\JoinColumn(nullable: true, onDelete: "SET NULL")]
  25. protected $city;
  26. #[ORM\Column(type: "string")]
  27. protected $address;
  28. public function getId()
  29. {
  30. return $this->id;
  31. }
  32. public function getName()
  33. {
  34. return $this->name;
  35. }
  36. public function setName($name)
  37. {
  38. $this->name = $name;
  39. }
  40. public function getCode()
  41. {
  42. return $this->code;
  43. }
  44. public function setCode($code)
  45. {
  46. $this->code = $code;
  47. }
  48. public function getCostCenter()
  49. {
  50. return $this->costCenter;
  51. }
  52. public function setCostCenter($costCenter)
  53. {
  54. $this->costCenter = $costCenter;
  55. }
  56. public function getCity()
  57. {
  58. return $this->city;
  59. }
  60. public function setCity($city)
  61. {
  62. $this->city = $city;
  63. }
  64. public function getAddress()
  65. {
  66. return $this->address;
  67. }
  68. public function getFullAddress()
  69. {
  70. return sprintf('%s, %s, %s', $this->address, $this->getCity(), $this->getCity()->getParent());
  71. }
  72. public function setAddress($address)
  73. {
  74. $this->address = $address;
  75. }
  76. public function __toString()
  77. {
  78. return sprintf('%s - %s', $this->code, $this->name);
  79. }
  80. public function getEnabled()
  81. {
  82. return $this->enabled;
  83. }
  84. public function setEnabled($enabled)
  85. {
  86. $this->enabled = $enabled;
  87. }
  88. public function getCostCenterSucursal()
  89. {
  90. return sprintf('%s- %s- %s', $this->code, $this->name, $this->costCenter);
  91. }
  92. }