src/Entity/MatchProfile.php line 33

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Controller\Api\AskForMatchProfileController;
  5. use App\Controller\Api\CheckMatchProfileController;
  6. use App\Repository\MatchProfileRepository;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. #[ORM\Entity(repositoryClassMatchProfileRepository::class)]
  11. #[ApiResource(
  12.     normalizationContext: ['groups' => ['profile','read_2']],
  13.     denormalizationContext: ['groups' => ['profile','post']],
  14.     collectionOperations: [
  15.         'get',
  16.         'post',
  17.         'askformatch'=> [
  18.             'method' => 'POST',
  19.             'path' => '/ask-for-match',
  20.             'controller' => AskForMatchProfileController::class,
  21.         ],
  22.        
  23.         
  24.     ],
  25.    
  26.    
  27.     
  28.     )]
  29. class MatchProfile
  30. {
  31.     #[ORM\Id]
  32.     #[ORM\GeneratedValue]
  33.     #[ORM\Column]
  34.     private ?int $id null;
  35.     #[ORM\Column(nullabletrue)]
  36.     #[Groups("profile")]
  37.     private ?bool $isMatchAccepted null;
  38.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  39.     #[Groups("profile")]
  40.     private ?\DateTimeInterface $askForMatchAt null;
  41.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  42.     #[Groups("profile")]
  43.     private ?\DateTimeInterface $ignoreMatchAt null;
  44.     
  45.     #[ORM\ManyToOne(inversedBy'askedMatches')]
  46.     #[Groups(["post"])]
  47.     private ?Profile $profileAskForMatch null;
  48.     #[ORM\ManyToOne(inversedBy'matchesByOthers')]
  49.     #[Groups(["post"])]
  50.    
  51.     private ?Profile $profileMatched null;
  52.     #[ORM\Column(nullabletrue)]
  53.     #[Groups("profile")]
  54.     private ?bool $isIgnored null;
  55.     #[ORM\Column(length255nullabletrue)]
  56.     // 3 Actions : like, dislike
  57.     private ?string $actionProfileAskForMatch;
  58.     #[ORM\Column(length255nullabletrue)]
  59.    
  60.     // 3 Actions : like, dislike
  61.     private ?string $actionProfileMatched;
  62.     #[ORM\Column(length255nullabletrue)]
  63.     #[Groups(["post","read_2"])]
  64.     // 3 Actions : like, dislike, match
  65.     private ?string $action;
  66.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  67.     private ?\DateTimeInterface $updatedAt null;
  68.     public function __construct()
  69.     {
  70.         $this->askForMatchAt = new \DateTime();
  71.     }
  72.     public function getId(): ?int
  73.     {
  74.         return $this->id;
  75.     }
  76.     public function getIsMatchAccepted(): ?bool
  77.     {
  78.         return $this->isMatchAccepted;
  79.     }
  80.     public function setIsMatchAccepted(?bool $isMatchAccepted): self
  81.     {
  82.         $this->isMatchAccepted $isMatchAccepted;
  83.         return $this;
  84.     }
  85.     public function getAskForMatchAt(): ?\DateTimeInterface
  86.     {
  87.         return $this->askForMatchAt;
  88.     }
  89.     public function setAskForMatchAt(?\DateTimeInterface $askForMatchAt): self
  90.     {
  91.         $this->askForMatchAt $askForMatchAt;
  92.         return $this;
  93.     }
  94.     public function getIgnoreMatchAt(): ?\DateTimeInterface
  95.     {
  96.         return $this->ignoreMatchAt;
  97.     }
  98.     public function setIgnoreMatchAt(?\DateTimeInterface $ignoreMatchAt): self
  99.     {
  100.         $this->ignoreMatchAt $ignoreMatchAt;
  101.         return $this;
  102.     }
  103.     public function getProfileAskForMatch(): ?Profile
  104.     {
  105.         return $this->profileAskForMatch;
  106.     }
  107.     public function setProfileAskForMatch(?Profile $profileAskForMatch): self
  108.     {
  109.         $this->profileAskForMatch $profileAskForMatch;
  110.         return $this;
  111.     }
  112.     public function getProfileMatched(): ?Profile
  113.     {
  114.         return $this->profileMatched;
  115.     }
  116.     public function setProfileMatched(?Profile $profileMatched): self
  117.     {
  118.         $this->profileMatched $profileMatched;
  119.         return $this;
  120.     }
  121.     public function getIsIgnored(): ?bool
  122.     {
  123.         return $this->isIgnored;
  124.     }
  125.     public function setIsIgnored(?bool $isIgnored): self
  126.     {
  127.         $this->isIgnored $isIgnored;
  128.         return $this;
  129.     }
  130.     #[Groups("profile")]
  131.     public function getProfileAskForMatchEmail(){
  132.         if($this->profileAskForMatch){
  133.             return $this->profileAskForMatch->getUser()->getEmail();
  134.         }
  135.         return null;
  136.         
  137.     }
  138.     #[Groups("profile")]
  139.     public function getProfileMatchedEmail(){
  140.         
  141.         if($this->profileMatched){
  142.             return $this->profileMatched->getUser()->getEmail();
  143.         }
  144.         return null;
  145.     }
  146.     public function getActionProfileAskForMatch(): ?string
  147.     {
  148.         return $this->actionProfileAskForMatch;
  149.     }
  150.     public function setActionProfileAskForMatch(?string $actionProfileAskForMatch): self
  151.     {
  152.         $this->actionProfileAskForMatch $actionProfileAskForMatch;
  153.         return $this;
  154.     }
  155.     public function getUpdatedAt(): ?\DateTimeInterface
  156.     {
  157.         return $this->updatedAt;
  158.     }
  159.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  160.     {
  161.         $this->updatedAt $updatedAt;
  162.         return $this;
  163.     }
  164.     /**
  165.      * Get the value of actionProfileMatched
  166.      */ 
  167.     public function getActionProfileMatched()
  168.     {
  169.         return $this->actionProfileMatched;
  170.     }
  171.     /**
  172.      * Set the value of actionProfileMatched
  173.      *
  174.      * @return  self
  175.      */ 
  176.     public function setActionProfileMatched($actionProfileMatched)
  177.     {
  178.         $this->actionProfileMatched $actionProfileMatched;
  179.         return $this;
  180.     }
  181.     /**
  182.      * Get the value of action
  183.      */ 
  184.     public function getAction()
  185.     {
  186.         return $this->action;
  187.     }
  188.     /**
  189.      * Set the value of action
  190.      *
  191.      * @return  self
  192.      */ 
  193.     public function setAction($action)
  194.     {
  195.         $this->action $action;
  196.         return $this;
  197.     }
  198. }