src/Entity/Account.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AccountRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9. * @Gedmo\Loggable()
  10. */
  11. #[UniqueEntity(fields: "name", message: "Ya existe una cuenta con ese nombre")]
  12. #[ORM\Entity(repositoryClass: AccountRepository::class)]
  13. #[ORM\Table(name: '`account`')]
  14. class Account
  15. {
  16. #[ORM\Id]
  17. #[ORM\GeneratedValue(strategy:"AUTO")]
  18. #[ORM\Column(type: "integer")]
  19. protected ?int $id = null;
  20. /**
  21. * @Gedmo\Versioned()
  22. */
  23. #[ORM\Column(type: "boolean")]
  24. private $enabled = true;
  25. /**
  26. * @Gedmo\Versioned()
  27. */
  28. #[Assert\NotBlank]
  29. #[ORM\Column(type: "string", nullable: true)]
  30. private $name;
  31. public static function create($name)
  32. {
  33. $self = new self;
  34. $self->setName($name);
  35. return $self;
  36. }
  37. public function getId()
  38. {
  39. return $this->id;
  40. }
  41. public function getName()
  42. {
  43. return $this->name;
  44. }
  45. public function setName(string $name)
  46. {
  47. $this->name = $name;
  48. }
  49. public function getEnabled()
  50. {
  51. return $this->enabled;
  52. }
  53. public function setEnabled($enabled)
  54. {
  55. $this->enabled = $enabled;
  56. }
  57. public function __toString()
  58. {
  59. return $this->name;
  60. }
  61. }