src/Entity/Payment.php line 40

  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use App\Repository\PaymentRepository;
  6. use ApiPlatform\Core\Annotation\ApiResource;
  7. use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Symfony\Component\Uid\Ulid;
  10. use Gedmo\Mapping\Annotation as Gedmo;
  11. #[ORM\Entity(repositoryClassPaymentRepository::class)]
  12. #[Gedmo\SoftDeleteable(fieldName'deletedAt'timeAwarefalsehardDeletetrue)]
  13. #[ORM\HasLifecycleCallbacks()]
  14. #[ApiResource(
  15.     attributes: ["security" => "is_granted('IS_AUTHENTICATED_FULLY')"],
  16.     itemOperations: [
  17.         'get' => [
  18.             'normalization_context' => [
  19.                 'groups' => [
  20.                     'read:payment:basic',
  21.                     'read:familymember:basic',
  22.                 ]
  23.             ]
  24.         ],
  25.     ],
  26.     collectionOperations: [
  27.         'get' => [
  28.             'normalization_context' => [
  29.                 'groups' => [
  30.                     'read:payment:basic',
  31.                     'read:familymember:basic',
  32.                 ]
  33.             ]
  34.         ],
  35.     ],
  36. )]
  37. class Payment
  38. {
  39.     use Timestamps;
  40.     #[ORM\Id]
  41.     #[ORM\Column(type'ulid'uniquetrue)]
  42.     #[ORM\GeneratedValue(strategy"CUSTOM")]
  43.     #[ORM\CustomIdGenerator(class: UlidGenerator::class)]
  44.     #[Groups(['read:payment:basic'])]
  45.     private ?Ulid $id null;
  46.     #[ORM\Column(type'float')]
  47.     #[Groups(['read:payment:basic'])]
  48.     private $amount 0;
  49.     #[ORM\Column(type'date')]
  50.     #[Groups(['read:payment:basic'])]
  51.     private $date;
  52.     #[ORM\Column(type'string'length255nullabletrue)]
  53.     #[Groups(['read:payment:basic'])]
  54.     private $description;
  55.     #[ORM\ManyToOne(targetEntitySubscription::class, inversedBy'payments')]
  56.     #[ORM\JoinColumn(nullablefalse)]
  57.     #[Groups(['read:payment:basic'])]
  58.     private $subscription;
  59.     #[ORM\ManyToOne(targetEntityFamilyMember::class, inversedBy'payments')]
  60.     #[Groups(['read:payment:basic'])]
  61.     private $payed_by;
  62.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'payments')]
  63.     #[ORM\JoinColumn(nullablefalse)]
  64.     private $created_by;
  65.     #[ORM\ManyToOne(targetEntityCompany::class, inversedBy'payments')]
  66.     #[ORM\JoinColumn(nullablefalse)]
  67.     private $owner;
  68.     #[ORM\ManyToOne(targetEntitySeason::class, inversedBy'payments')]
  69.     #[ORM\JoinColumn(nullablefalse)]
  70.     private $season;
  71.     public function __construct()
  72.     {
  73.         $this->date = new DateTime();
  74.     }
  75.     public function getId(): ?Ulid
  76.     {
  77.         return $this->id;
  78.     }
  79.     public function getAmount(): ?float
  80.     {
  81.         return $this->amount;
  82.     }
  83.     public function setAmount(float $amount): self
  84.     {
  85.         $this->amount $amount;
  86.         return $this;
  87.     }
  88.     public function getDate(): ?\DateTimeInterface
  89.     {
  90.         return $this->date;
  91.     }
  92.     public function setDate(\DateTimeInterface $date): self
  93.     {
  94.         $this->date $date;
  95.         return $this;
  96.     }
  97.     public function getDescription(): ?string
  98.     {
  99.         return $this->description;
  100.     }
  101.     public function setDescription(string $description): self
  102.     {
  103.         $this->description $description;
  104.         return $this;
  105.     }
  106.     public function getSubscription(): ?Subscription
  107.     {
  108.         return $this->subscription;
  109.     }
  110.     public function setSubscription(?Subscription $subscription): self
  111.     {
  112.         $this->subscription $subscription;
  113.         return $this;
  114.     }
  115.     public function getPayedBy(): ?FamilyMember
  116.     {
  117.         return $this->payed_by;
  118.     }
  119.     public function setPayedBy(?FamilyMember $payed_by): self
  120.     {
  121.         $this->payed_by $payed_by;
  122.         return $this;
  123.     }
  124.     public function getCreatedBy(): ?User
  125.     {
  126.         return $this->created_by;
  127.     }
  128.     public function setCreatedBy(?User $created_by): self
  129.     {
  130.         $this->created_by $created_by;
  131.         return $this;
  132.     }
  133.     public function getOwner(): ?Company
  134.     {
  135.         return $this->owner;
  136.     }
  137.     public function setOwner(?Company $owner): self
  138.     {
  139.         $this->owner $owner;
  140.         return $this;
  141.     }
  142.     public function getSeason(): ?Season
  143.     {
  144.         return $this->season;
  145.     }
  146.     public function setSeason(?Season $season): self
  147.     {
  148.         $this->season $season;
  149.         return $this;
  150.     }
  151. }