WIP: Implement feedback functionality
This commit is contained in:
@@ -15,6 +15,9 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface
|
||||
use BlameableEntity;
|
||||
use TimestampableEntity;
|
||||
|
||||
public const STATUS_NEW = 'new';
|
||||
public const STATUS_PUBLISHED = 'published';
|
||||
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
@@ -23,6 +26,9 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface
|
||||
#[ORM\Column(type: 'string', length: 36, unique: true)]
|
||||
private string $uuid;
|
||||
|
||||
#[ORM\Column(length: 32)]
|
||||
private ?string $status = self::STATUS_NEW;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'feedback')]
|
||||
private ?Teamer $teamer = null;
|
||||
|
||||
@@ -56,6 +62,18 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface
|
||||
return $this->uuid;
|
||||
}
|
||||
|
||||
public function getStatus(): ?string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function setStatus(string $status): static
|
||||
{
|
||||
$this->status = $status;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTeamer(): ?Teamer
|
||||
{
|
||||
return $this->teamer;
|
||||
@@ -104,6 +122,21 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAverageRating(): ?int
|
||||
{
|
||||
if (0 === count($this->ratings)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$sum = 0;
|
||||
|
||||
foreach ($this->ratings as $rating) {
|
||||
$sum += $rating['mark'];
|
||||
}
|
||||
|
||||
return round($sum/count($this->ratings));
|
||||
}
|
||||
|
||||
public function getComment(): ?string
|
||||
{
|
||||
return $this->comment;
|
||||
|
||||
Reference in New Issue
Block a user