src/Entity/WalletOperation.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\WalletOperationRepository;
  4. use App\Trait\ArrayableTrait;
  5. use App\Trait\AuthorTrait;
  6. use App\Trait\DateTrait;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. #[ORM\Entity(repositoryClassWalletOperationRepository::class)]
  10. class WalletOperation
  11. {
  12.     use ArrayableTrait;
  13.     use DateTrait {DateTrait::__construct as private dateConstruct;}
  14.     use AuthorTrait;
  15.     const CREDITE "wallet.operation.type.credite";
  16.     const DEBITE "wallet.operation.type.debite";
  17.     const TRANSFERT "wallet.operation.type.transfer";
  18.     const WALLET_CARD "wallet.operation.for.card";
  19.     const WALLET_MEMBER "wallet.operation.for.member";
  20.     const WALLET_DEPARTMENT "wallet.operation.for.department";
  21.     const WALLET_CLIENT "wallet.operation.for.client";
  22.     const WALLET_EMPLOYEE "wallet.operation.for.employee";
  23.     const STATUS_SUCCESS "wallet.operation.status.success";
  24.     const STATUS_ERROR "wallet.operation.status.error";
  25.     const STATUS_CANCEL "wallet.operation.status.cancel";
  26.     #[ORM\Id]
  27.     #[ORM\GeneratedValue]
  28.     #[ORM\Column]
  29.     private ?int $id null;
  30.     #[ORM\Column(length255)]
  31.     #[Assert\NotBlank]
  32.     #[Assert\Choice(callback: [self::class, 'getOperations'])]
  33.     private ?string $type null;
  34.     #[ORM\Column(length255nullabletrue)]
  35.     private ?string $fromEntity null;
  36.     #[ORM\Column(nullabletrue)]
  37.     private ?int $fromId null;
  38.     #[ORM\Column(length255)]
  39.     private ?string $toEntity null;
  40.     #[ORM\Column]
  41.     private ?int $toId null;
  42.     #[ORM\Column(length255)]
  43.     private ?string $status null;
  44.     #[ORM\Column]
  45.     #[Assert\NotBlank]
  46.     private ?float $amount null;
  47.     #[ORM\ManyToOne(inversedBy'walletOperations')]
  48.     #[ORM\JoinColumn(nullablefalse)]
  49.     #[Assert\NotBlank]
  50.     private ?Currency $currency null;
  51.     #[ORM\Column(length255nullabletrue)]
  52.     private ?string $motif null;
  53.     #[ORM\ManyToOne(inversedBy'walletOperations')]
  54.     private ?Establishment $establishment null;
  55.     public static function getOperations(): array
  56.     {
  57.         return [
  58.             self::CREDITE,
  59.             self::DEBITE,
  60.             self::TRANSFERT,
  61.         ];
  62.     }
  63.     public static function getWalletable(): array
  64.     {
  65.         return [
  66.             self::WALLET_CARD => 'Card',
  67.             self::WALLET_EMPLOYEE => 'Employee',
  68.             self::WALLET_MEMBER => 'Mutuality',
  69.             self::WALLET_CLIENT => 'Client',
  70.             self::WALLET_DEPARTMENT => 'Department',
  71.         ];
  72.     }
  73.     public function getId(): ?int
  74.     {
  75.         return $this->id;
  76.     }
  77.     public function getType(): ?string
  78.     {
  79.         return $this->type;
  80.     }
  81.     public function setType(string $type): static
  82.     {
  83.         $this->type $type;
  84.         return $this;
  85.     }
  86.     public function getFromEntity(): ?string
  87.     {
  88.         return $this->fromEntity;
  89.     }
  90.     public function setFromEntity(?string $fromEntity): static
  91.     {
  92.         $this->fromEntity $fromEntity;
  93.         return $this;
  94.     }
  95.     public function getFromId(): ?int
  96.     {
  97.         return $this->fromId;
  98.     }
  99.     public function setFromId(?int $fromId): static
  100.     {
  101.         $this->fromId $fromId;
  102.         return $this;
  103.     }
  104.     public function getToEntity(): ?string
  105.     {
  106.         return $this->toEntity;
  107.     }
  108.     public function setToEntity(string $toEntity): static
  109.     {
  110.         $this->toEntity $toEntity;
  111.         return $this;
  112.     }
  113.     public function getToId(): ?int
  114.     {
  115.         return $this->toId;
  116.     }
  117.     public function setToId(int $toId): static
  118.     {
  119.         $this->toId $toId;
  120.         return $this;
  121.     }
  122.     public function getStatus(): ?string
  123.     {
  124.         return $this->status;
  125.     }
  126.     public function setStatus(string $status): static
  127.     {
  128.         $this->status $status;
  129.         return $this;
  130.     }
  131.     public function getAmount(): ?float
  132.     {
  133.         return $this->amount;
  134.     }
  135.     public function setAmount(float $amount): static
  136.     {
  137.         $this->amount $amount;
  138.         return $this;
  139.     }
  140.     public function getCurrency(): ?Currency
  141.     {
  142.         return $this->currency;
  143.     }
  144.     public function setCurrency(?Currency $currency): static
  145.     {
  146.         $this->currency $currency;
  147.         return $this;
  148.     }
  149.     public function getMotif(): ?string
  150.     {
  151.         return $this->motif;
  152.     }
  153.     public function setMotif(?string $motif): static
  154.     {
  155.         $this->motif $motif;
  156.         return $this;
  157.     }
  158.     public function getEstablishment(): ?Establishment
  159.     {
  160.         return $this->establishment;
  161.     }
  162.     public function setEstablishment(?Establishment $establishment): static
  163.     {
  164.         $this->establishment $establishment;
  165.         return $this;
  166.     }
  167. }