<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Controller\Api\AskForMatchProfileController;
use App\Controller\Api\CheckMatchProfileController;
use App\Repository\MatchProfileRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: MatchProfileRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['profile','read_2']],
denormalizationContext: ['groups' => ['profile','post']],
collectionOperations: [
'get',
'post',
'askformatch'=> [
'method' => 'POST',
'path' => '/ask-for-match',
'controller' => AskForMatchProfileController::class,
],
],
)]
class MatchProfile
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(nullable: true)]
#[Groups("profile")]
private ?bool $isMatchAccepted = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
#[Groups("profile")]
private ?\DateTimeInterface $askForMatchAt = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
#[Groups("profile")]
private ?\DateTimeInterface $ignoreMatchAt = null;
#[ORM\ManyToOne(inversedBy: 'askedMatches')]
#[Groups(["post"])]
private ?Profile $profileAskForMatch = null;
#[ORM\ManyToOne(inversedBy: 'matchesByOthers')]
#[Groups(["post"])]
private ?Profile $profileMatched = null;
#[ORM\Column(nullable: true)]
#[Groups("profile")]
private ?bool $isIgnored = null;
#[ORM\Column(length: 255, nullable: true)]
// 3 Actions : like, dislike
private ?string $actionProfileAskForMatch;
#[ORM\Column(length: 255, nullable: true)]
// 3 Actions : like, dislike
private ?string $actionProfileMatched;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(["post","read_2"])]
// 3 Actions : like, dislike, match
private ?string $action;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $updatedAt = null;
public function __construct()
{
$this->askForMatchAt = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getIsMatchAccepted(): ?bool
{
return $this->isMatchAccepted;
}
public function setIsMatchAccepted(?bool $isMatchAccepted): self
{
$this->isMatchAccepted = $isMatchAccepted;
return $this;
}
public function getAskForMatchAt(): ?\DateTimeInterface
{
return $this->askForMatchAt;
}
public function setAskForMatchAt(?\DateTimeInterface $askForMatchAt): self
{
$this->askForMatchAt = $askForMatchAt;
return $this;
}
public function getIgnoreMatchAt(): ?\DateTimeInterface
{
return $this->ignoreMatchAt;
}
public function setIgnoreMatchAt(?\DateTimeInterface $ignoreMatchAt): self
{
$this->ignoreMatchAt = $ignoreMatchAt;
return $this;
}
public function getProfileAskForMatch(): ?Profile
{
return $this->profileAskForMatch;
}
public function setProfileAskForMatch(?Profile $profileAskForMatch): self
{
$this->profileAskForMatch = $profileAskForMatch;
return $this;
}
public function getProfileMatched(): ?Profile
{
return $this->profileMatched;
}
public function setProfileMatched(?Profile $profileMatched): self
{
$this->profileMatched = $profileMatched;
return $this;
}
public function getIsIgnored(): ?bool
{
return $this->isIgnored;
}
public function setIsIgnored(?bool $isIgnored): self
{
$this->isIgnored = $isIgnored;
return $this;
}
#[Groups("profile")]
public function getProfileAskForMatchEmail(){
if($this->profileAskForMatch){
return $this->profileAskForMatch->getUser()->getEmail();
}
return null;
}
#[Groups("profile")]
public function getProfileMatchedEmail(){
if($this->profileMatched){
return $this->profileMatched->getUser()->getEmail();
}
return null;
}
public function getActionProfileAskForMatch(): ?string
{
return $this->actionProfileAskForMatch;
}
public function setActionProfileAskForMatch(?string $actionProfileAskForMatch): self
{
$this->actionProfileAskForMatch = $actionProfileAskForMatch;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* Get the value of actionProfileMatched
*/
public function getActionProfileMatched()
{
return $this->actionProfileMatched;
}
/**
* Set the value of actionProfileMatched
*
* @return self
*/
public function setActionProfileMatched($actionProfileMatched)
{
$this->actionProfileMatched = $actionProfileMatched;
return $this;
}
/**
* Get the value of action
*/
public function getAction()
{
return $this->action;
}
/**
* Set the value of action
*
* @return self
*/
public function setAction($action)
{
$this->action = $action;
return $this;
}
}