src/Entity/Operation.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\OperationRepository;
  4. use DateTime;
  5. use DateTimeInterface;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClass: OperationRepository::class)]
  9. class Operation
  10. {
  11.     public const ENTRANCE = 'ENTRANCE';
  12.     public const EXIT = 'EXIT';
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id = null;
  17.     #[ORM\Column(length: 255)]
  18.     private ?string $type = null;
  19.     #[ORM\Column(type: Types::TEXT, nullable: true)]
  20.     private ?string $motif = null;
  21.     #[ORM\ManyToOne]
  22.     #[ORM\JoinColumn(nullable: false)]
  23.     private ?User $author = null;
  24.     #[ORM\ManyToOne(inversedBy: 'operations')]
  25.     #[ORM\JoinColumn(nullable: false)]
  26.     private ?Establishment $establishment = null;
  27.     #[ORM\Column]
  28.     private ?float $amount = null;
  29.     #[ORM\ManyToOne]
  30.     #[ORM\JoinColumn(nullable: false)]
  31.     private ?Currency $currency = null;
  32.     #[ORM\Column(type: Types::DATETIME_MUTABLE)]
  33.     private ?DateTimeInterface $createdAt;
  34.     public function __construct()
  35.     {
  36.         $this->createdAt = new DateTime();
  37.     }
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     public function getType(): ?string
  43.     {
  44.         return $this->type;
  45.     }
  46.     public function setType(string $type): self
  47.     {
  48.         $this->type = $type;
  49.         return $this;
  50.     }
  51.     public static function getTypeList()
  52.     {
  53.         return [
  54.             "EntrĂ©e" => self::ENTRANCE,
  55.             "Sortie" => self::EXIT,
  56.         ];
  57.     }
  58.     public function getMotif(): ?string
  59.     {
  60.         return $this->motif;
  61.     }
  62.     public function setMotif(?string $motif): self
  63.     {
  64.         $this->motif = $motif;
  65.         return $this;
  66.     }
  67.     public function getAuthor(): ?User
  68.     {
  69.         return $this->author;
  70.     }
  71.     public function setAuthor(?User $author): self
  72.     {
  73.         $this->author = $author;
  74.         return $this;
  75.     }
  76.     public function getEstablishment(): ?Establishment
  77.     {
  78.         return $this->establishment;
  79.     }
  80.     public function setEstablishment(?Establishment $establishment): self
  81.     {
  82.         $this->establishment = $establishment;
  83.         return $this;
  84.     }
  85.     public function getAmount(): ?float
  86.     {
  87.         return $this->amount;
  88.     }
  89.     public function setAmount(float $amount): self
  90.     {
  91.         $this->amount = $amount;
  92.         return $this;
  93.     }
  94.     public function getCurrency(): ?Currency
  95.     {
  96.         return $this->currency;
  97.     }
  98.     public function setCurrency(?Currency $currency): self
  99.     {
  100.         $this->currency = $currency;
  101.         return $this;
  102.     }
  103.     public function getCreatedAt(): ?DateTimeInterface
  104.     {
  105.         return $this->createdAt;
  106.     }
  107.     public function setCreatedAt(DateTimeInterface $createdAt): self
  108.     {
  109.         $this->createdAt = $createdAt;
  110.         return $this;
  111.     }
  112. }