src/Entity/User/Payment/Iban.php line 51

Open in your IDE?
  1. <?php
  2. namespace App\Entity\User\Payment;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Entity\User\User;
  5. use App\Repository\User\Payment\IbanRepository;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Timestampable\Traits\TimestampableEntity;
  8. use Ramsey\Uuid\Doctrine\UuidGenerator;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Component\Serializer\Annotation\SerializedName;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use App\Controller\Api\CreateAloneIbanBicByUser;
  13. /**
  14.  * @ApiResource(
  15.  *     attributes={
  16.  *          "normalization_context"={"groups"={
  17.  *              "IBAN:output",
  18.  *              "IBAN:io",
  19.  *              "new_iban"
  20.  *          }},
  21.  *          "denormalization_context"={"groups"={
  22.  *              "IBAN:input",
  23.  *              "IBAN:io",
  24.  *          }}
  25.  *      },
  26.  *     collectionOperations={
  27.  *          "post"={
  28.  *              "validation_groups"={"Default", "Create"}
  29.  *          },
  30.  *          "get"={},
  31.  *          "postAloneIbanBic"={
  32.  *              "method"="POST",
  33.  *              "path"="/ibans/alone",
  34.  *              "validation_groups"={"new_iban"},
  35.  *              "controller"=CreateAloneIbanBicByUser::class,
  36.  *          },
  37.  *     },
  38.  *     itemOperations={
  39.  *          "delete"={},
  40.  *          "get"={},
  41.  *          "put"={
  42.  *              "validation_groups"={"Default", "Edit"}
  43.  *          }
  44.  *     }
  45.  * )
  46.  * @ORM\Entity(repositoryClass=IbanRepository::class)
  47.  */
  48. class Iban
  49. {
  50.     /**
  51.      * Hook timestampable behavior
  52.      * updates createdAt, updatedAt fields
  53.      */
  54.     use TimestampableEntity;
  55.     /**
  56.      * @ORM\Id
  57.      * @ORM\Column(type="uuid", unique=true)
  58.      * @ORM\GeneratedValue(strategy="CUSTOM")
  59.      * @ORM\CustomIdGenerator(class=UuidGenerator::class)
  60.      * @SerializedName("id")
  61.      * @Assert\Uuid()
  62.      * @Groups({
  63.      *     "IBAN:output",
  64.      *     "User:io",
  65.      * })
  66.      */
  67.     private string $id;
  68.     /**
  69.      * @ORM\Column(type="string", length=50)
  70.      * @SerializedName("label")
  71.      * @Assert\NotBlank()
  72.      * @Groups({
  73.      *     "IBAN:io",
  74.      *     "new_iban",
  75.      * })
  76.      */
  77.     private string $label;
  78.     /**
  79.      * @ORM\Column(type="string")
  80.      * @SerializedName("account_number")
  81.      * @Assert\NotBlank()
  82.      * @Assert\Iban()
  83.      * @Groups({
  84.      *     "IBAN:io",
  85.      *     "new_iban",
  86.      *     "User:io",
  87.      * })
  88.      */
  89.     private string $accountNumber;
  90.     /**
  91.      * @ORM\Column(type="string", name="hidden_account_number", nullable=true)
  92.      * @SerializedName("hidden_account_number")
  93.      * @Groups({
  94.      *     "IBAN:io",
  95.      *     "new_iban",
  96.      *     "User:io",
  97.      * })
  98.      */
  99.     private ?string $hiddenAccountNumber null;
  100.     /**
  101.      * @ORM\Column(type="string", length=11, nullable=true)
  102.      * @SerializedName("bic")
  103.      * @Assert\NotBlank()
  104.      * @Assert\Length(min="8", max="11")
  105.      * @Groups({
  106.      *     "IBAN:io",
  107.      *     "new_iban",
  108.      *     "User:io",
  109.      * })
  110.      */
  111.     private ?string $BIC;
  112.     /**
  113.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="ibans")
  114.      * @SerializedName("user")
  115.      * @ORM\JoinColumn(nullable=false)
  116.      * @Groups({"IBAN:io"})
  117.      */
  118.     private $user;
  119.     /**
  120.      * @ORM\Column(type="string", length=180, nullable=true)
  121.      * @SerializedName("paypal")
  122.      * @Groups({
  123.      *     "IBAN:io",
  124.      *     "new_iban",
  125.      *     "User:io",
  126.      * })
  127.      */
  128.     private ?string $paypal null;
  129.     /**
  130.      * @return string
  131.      */
  132.     public function getId(): ?string
  133.     {
  134.         return $this->id;
  135.     }
  136.     public function getLabel(): ?string
  137.     {
  138.         return $this->label;
  139.     }
  140.     public function setLabel(string $label): self
  141.     {
  142.         $this->label $label;
  143.         return $this;
  144.     }
  145.     public function getAccountNumber(): ?string
  146.     {
  147.         return $this->accountNumber;
  148.     }
  149.     public function setAccountNumber(string $accountNumber): self
  150.     {
  151.         $accountNumber str_replace(' '''$accountNumber);
  152.         $this->accountNumber $accountNumber;
  153.         return $this;
  154.     }
  155.     public function getHiddenAccountNumber(): ?string
  156.     {
  157.         return $this->hiddenAccountNumber;
  158.     }
  159.     public function setHiddenAccountNumber(string $hiddenAccountNumber): self
  160.     {
  161.         $this->hiddenAccountNumber $hiddenAccountNumber;
  162.         return $this;
  163.     }
  164.     public function getBIC(): ?string
  165.     {
  166.         return $this->BIC;
  167.     }
  168.     public function setBIC(?string $BIC): self
  169.     {
  170.         $BIC str_replace(' '''$BIC);
  171.         $this->BIC $BIC;
  172.         return $this;
  173.     }
  174.     public function getUser(): ?User
  175.     {
  176.         return $this->user;
  177.     }
  178.     public function setUser(?User $user): self
  179.     {
  180.         $this->user $user;
  181.         return $this;
  182.     }
  183.     public function getPaypal(): ?string
  184.     {
  185.         return $this->paypal;
  186.     }
  187.     public function setPaypal(?string $paypal): self
  188.     {
  189.         $this->paypal $paypal;
  190.         return $this;
  191.     }
  192. }