Rebuild the doctor rating/review system to power the public site's rich
review UI, and restrict who may submit.
Ratings:
- Rate entity holds five 0–100 dimensions (waiting time, diagnosis
accuracy, behaviour, cleanliness, expertise) instead of a single score.
- GET /rate/{uuid} returns aggregate {point, satisfaction, averages[]}.
- POST /rate upserts all five dimensions and returns the new aggregate.
Comments:
- Comment gains parent/replies (threaded) and a rich toArray with author,
like_status (like/dislike counts + current user's vote) and nested
approved replies. POST /comment accepts {comment, parent}.
- Likes are directional (value 1=like, -1=dislike) with toggle/replace;
POST /like/{uuid} returns like_count/dislike_count/current_user_like.
Eligibility:
- Only a user with a confirmed appointment in the last 30 days may rate or
comment (AppointmentRepository::hasRecentConfirmed); otherwise
403 ERR_RATING_NOT_ELIGIBLE. New GET /rate/{uuid}/eligibility for the UI.
- security.yaml: narrow the public rate pattern so /eligibility stays auth'd.
Also updates admin rates listing to the new dimensions and the rating/admin
API docs. Includes migration for the new columns.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
40 lines
1.7 KiB
PHP
40 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
/**
|
|
* Auto-generated Migration: Please modify to your needs!
|
|
*/
|
|
final class Version20260615203529 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return '';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
// this up() migration is auto-generated, please modify it to your needs
|
|
$this->addSql('ALTER TABLE comments ADD parent_id INT DEFAULT NULL');
|
|
$this->addSql('ALTER TABLE comments ADD CONSTRAINT FK_5F9E962A727ACA70 FOREIGN KEY (parent_id) REFERENCES comments (id) ON DELETE CASCADE');
|
|
$this->addSql('CREATE INDEX IDX_5F9E962A727ACA70 ON comments (parent_id)');
|
|
$this->addSql('ALTER TABLE likes ADD value SMALLINT NOT NULL');
|
|
$this->addSql('ALTER TABLE rates ADD accuracy_of_diagnosis SMALLINT NOT NULL, ADD doctor_behavior SMALLINT NOT NULL, ADD clinic_cleanliness SMALLINT NOT NULL, ADD doctor_expertise SMALLINT NOT NULL, CHANGE score waiting_time_at_clinic SMALLINT NOT NULL');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
// this down() migration is auto-generated, please modify it to your needs
|
|
$this->addSql('ALTER TABLE comments DROP FOREIGN KEY FK_5F9E962A727ACA70');
|
|
$this->addSql('DROP INDEX IDX_5F9E962A727ACA70 ON comments');
|
|
$this->addSql('ALTER TABLE comments DROP parent_id');
|
|
$this->addSql('ALTER TABLE likes DROP value');
|
|
$this->addSql('ALTER TABLE rates ADD score SMALLINT NOT NULL, DROP waiting_time_at_clinic, DROP accuracy_of_diagnosis, DROP doctor_behavior, DROP clinic_cleanliness, DROP doctor_expertise');
|
|
}
|
|
}
|