src/Entity/ChannelUser.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'ChannelUser')]
  11. class ChannelUser
  12. {
  13.     use TimestampableEntity;
  14.     
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column(type'integer')]
  18.     private $id;
  19.     #[ORM\ManyToOne(targetEntityChannel::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 $channel;
  28.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'channels')]
  29.     #[Groups([
  30.         'channel:item:get',
  31.     ])]
  32.     private $user;
  33.     #[ApiProperty()]
  34.     #[Groups([
  35.         'channel:item:get',
  36.     ])]
  37.     private $userIdentifier;
  38.     #[ApiProperty()]
  39.     #[Groups([
  40.         'channel:item:get',
  41.     ])]
  42.     private $avatar;
  43.     public function getId(): ?int
  44.     {
  45.         return $this->id;
  46.     }
  47.     public function getChannel(): ?Channel
  48.     {
  49.         return $this->channel;
  50.     }
  51.     public function setChannel(?Channel $channel): self
  52.     {
  53.         $this->channel $channel;
  54.         return $this;
  55.     }
  56.     public function getUser(): ?User
  57.     {
  58.         return $this->user;
  59.     }
  60.     public function setUser(?User $user): self
  61.     {
  62.         $this->user $user;
  63.         return $this;
  64.     }
  65.     public function getUserIdentifier(): ?string
  66.     {
  67.         return $this->getUser()->getUserIdentifier();
  68.     }
  69.     public function getAvatar(): ?string
  70.     {
  71.         return $this->getUser()->getAvatar() ? $this->getUser()->getAvatar()->getContentUrl() : false;
  72.     }
  73. }