src/Entity/CategorieMarche.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CategorieMarcheRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. #[ORM\Entity(repositoryClass: CategorieMarcheRepository::class)]
  9. #[ORM\Table(name: "CategorieMarche")]
  10. class CategorieMarche
  11. {
  12. #[ORM\Id]
  13. #[ORM\GeneratedValue]
  14. #[ORM\Column]
  15. private ?int $id = null;
  16. #[ORM\Column(length: 255)]
  17. #[Assert\NotBlank(message: "Le libellé est obligatoire.")]
  18. private ?string $libelle = null;
  19. #[ORM\Column(length: 20, unique: true)]
  20. private ?string $code = null;
  21. #[ORM\Column(type: 'text', nullable: true)]
  22. private ?string $description = null;
  23. #[ORM\Column]
  24. private bool $actif = true;
  25. #[ORM\OneToMany(
  26. mappedBy: 'categorieMarche',
  27. targetEntity: Fournisseur::class
  28. )]
  29. private Collection $fournisseurs;
  30. public function __construct()
  31. {
  32. $this->fournisseurs = new ArrayCollection();
  33. }
  34. // ===== Getters / Setters =====
  35. public function getId(): ?int { return $this->id; }
  36. public function getLibelle(): ?string { return $this->libelle; }
  37. public function setLibelle(string $v): self { $this->libelle = $v; return $this; }
  38. public function getCode(): ?string { return $this->code; }
  39. public function setCode(string $v): self { $this->code = strtoupper($v); return $this; }
  40. public function getDescription(): ?string { return $this->description; }
  41. public function setDescription(?string $v): self { $this->description = $v; return $this; }
  42. public function isActif(): bool { return $this->actif; }
  43. public function setActif(bool $v): self { $this->actif = $v; return $this; }
  44. public function getFournisseurs(): Collection { return $this->fournisseurs; }
  45. public function __toString(): string
  46. {
  47. return $this->libelle ?? '';
  48. }
  49. }