|
|
@ -240,12 +240,17 @@ class Message |
|
|
|
protected Collection $attachments; |
|
|
|
protected Collection $attachments; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @var Collection|MessageFeedback[] |
|
|
|
* @var Collection<int, MessageFeedback> |
|
|
|
* |
|
|
|
* |
|
|
|
* @ORM\OneToMany(targetEntity="MessageFeedback", mappedBy="message", orphanRemoval=true) |
|
|
|
* @ORM\OneToMany(targetEntity="MessageFeedback", mappedBy="message", orphanRemoval=true) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected Collection $likes; |
|
|
|
protected Collection $likes; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[Groups(['message:read'])] |
|
|
|
|
|
|
|
protected int $countLikes = 0; |
|
|
|
|
|
|
|
#[Groups(['message:read'])] |
|
|
|
|
|
|
|
protected int $countDislikes = 0; |
|
|
|
|
|
|
|
|
|
|
|
public function __construct() |
|
|
|
public function __construct() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->sendDate = new DateTime('now'); |
|
|
|
$this->sendDate = new DateTime('now'); |
|
|
@ -545,4 +550,24 @@ class Message |
|
|
|
|
|
|
|
|
|
|
|
return $this; |
|
|
|
return $this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getCountLikes(): int |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$criteria = Criteria::create(); |
|
|
|
|
|
|
|
$criteria->where( |
|
|
|
|
|
|
|
Criteria::expr()->eq('liked', true) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this->likes->matching($criteria)->count(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getCountDislikes(): int |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$criteria = Criteria::create(); |
|
|
|
|
|
|
|
$criteria->where( |
|
|
|
|
|
|
|
Criteria::expr()->eq('disliked', true) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this->likes->matching($criteria)->count(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|