src/Entity/InsuredUser.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiProperty;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use App\Repository\InsuredUserRepository;
  6. use App\Trait\TimestampableEntity;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Symfony\Component\Serializer\Annotation\MaxDepth;
  10. #[ORM\Entity(repositoryClassInsuredUserRepository::class)]
  11. #[ApiResource(iri'InsuredUser')]
  12. class InsuredUser
  13. {
  14.     use TimestampableEntity;
  15.     
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column(type'integer')]
  19.     private $id;
  20.     #[ApiProperty()]
  21.     #[Groups([
  22.         'user:collection:post',
  23.         'user:item:get',
  24.         'user:item:put',
  25.     ])]
  26.     #[MaxDepth(1)]
  27.     #[ORM\ManyToOne(targetEntityInsured::class, inversedBy'users')]
  28.     private $insured;
  29.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'insureds'cascade: ["persist"])]
  30.     #[Groups([
  31.         'insured:item:get',
  32.     ])]
  33.     private $user;
  34.     #[ApiProperty()]
  35.     #[Groups([
  36.         'import:insured',
  37.         'insured:item:get',
  38.     ])]
  39.     private $userIdentifier;
  40.     #[ApiProperty()]
  41.     #[Groups([
  42.         'insured:item:get',
  43.     ])]
  44.     private $avatar;
  45.     public function getId(): ?int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getInsured(): ?Insured
  50.     {
  51.         return $this->insured;
  52.     }
  53.     public function setInsured(?Insured $insured): self
  54.     {
  55.         $this->insured $insured;
  56.         return $this;
  57.     }
  58.     public function getUser(): ?User
  59.     {
  60.         return $this->user;
  61.     }
  62.     public function setUser(?User $user): self
  63.     {
  64.         $this->user $user;
  65.         return $this;
  66.     }
  67.     public function getUserIdentifier(): ?string
  68.     {
  69.         return $this->getUser()->getUserIdentifier();
  70.     }
  71.     public function getAvatar(): ?string
  72.     {
  73.         return $this->getUser()->getAvatar() ? $this->getUser()->getAvatar()->getContentUrl() : false;
  74.     }
  75. }