src/Entity/BrokerUser.php line 14

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\Trait\TimestampableEntity;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. use Symfony\Component\Serializer\Annotation\MaxDepth;
  9. #[ORM\Entity]
  10. #[ApiResource(iri'BrokerUser')]
  11. class BrokerUser
  12. {
  13.     use TimestampableEntity;
  14.     
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column(type'integer')]
  18.     private $id;
  19.     #[ORM\ManyToOne(targetEntityBroker::class, inversedBy'users')]
  20.     #[ApiProperty()]
  21.     #[Groups([
  22.         'user:collection:post',
  23.         'user:item:get',
  24.         'user:item:put',
  25.     ])]
  26.     #[MaxDepth(1)]
  27.     private $broker;
  28.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'brokers')]
  29.     #[Groups([
  30.         'broker:item:get',
  31.     ])]
  32.     private $user;
  33.     #[ApiProperty()]
  34.     #[Groups([
  35.         'broker:item:get',
  36.     ])]
  37.     private $userIdentifier;
  38.     #[ApiProperty()]
  39.     #[Groups([
  40.         'broker:item:get',
  41.     ])]
  42.     private $roles;
  43.     #[ApiProperty()]
  44.     #[Groups([
  45.         'broker:item:get',
  46.     ])]
  47.     private $avatar;
  48.     public function getId(): ?int
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getBroker(): ?Broker
  53.     {
  54.         return $this->broker;
  55.     }
  56.     public function setBroker(?Broker $broker): self
  57.     {
  58.         $this->broker $broker;
  59.         return $this;
  60.     }
  61.     public function getUser(): ?User
  62.     {
  63.         return $this->user;
  64.     }
  65.     public function setUser(?User $user): self
  66.     {
  67.         $this->user $user;
  68.         return $this;
  69.     }
  70.     public function getUserIdentifier(): ?string
  71.     {
  72.         return $this->getUser()->getUserIdentifier();
  73.     }
  74.     public function getRoles(): array
  75.     {
  76.         return $this->getUser()->getRoles();
  77.     }
  78.     public function getAvatar(): ?string
  79.     {
  80.         return $this->getUser()->getAvatar() ? $this->getUser()->getAvatar()->getContentUrl() : false;
  81.     }
  82. }