feat: add social media links field to Doctor entity and update API documentation
This commit is contained in:
@@ -278,6 +278,18 @@ class DoctorController extends BaseController
|
||||
items: new OA\Items(type: 'integer'),
|
||||
nullable: true,
|
||||
),
|
||||
new OA\Property(
|
||||
property: 'social_media',
|
||||
type: 'object',
|
||||
nullable: true,
|
||||
properties: [
|
||||
new OA\Property(property: 'instagram', type: 'string', nullable: true),
|
||||
new OA\Property(property: 'telegram', type: 'string', nullable: true),
|
||||
new OA\Property(property: 'aparat', type: 'string', nullable: true),
|
||||
new OA\Property(property: 'youtube', type: 'string', nullable: true),
|
||||
new OA\Property(property: 'linkedin', type: 'string', nullable: true),
|
||||
],
|
||||
),
|
||||
]
|
||||
)
|
||||
),
|
||||
@@ -725,6 +737,19 @@ class DoctorController extends BaseController
|
||||
$doctor->setImages($data['images']);
|
||||
}
|
||||
|
||||
// Social media links (each key nullable, must be a valid URL when present)
|
||||
if (array_key_exists('social_media', $data) && is_array($data['social_media'])) {
|
||||
$allowedKeys = ['instagram', 'telegram', 'aparat', 'youtube', 'linkedin'];
|
||||
$socialMedia = [];
|
||||
foreach ($allowedKeys as $key) {
|
||||
$value = $data['social_media'][$key] ?? null;
|
||||
$socialMedia[$key] = (is_string($value) && filter_var($value, FILTER_VALIDATE_URL))
|
||||
? $value
|
||||
: null;
|
||||
}
|
||||
$doctor->setSocialMedia($socialMedia);
|
||||
}
|
||||
|
||||
// Specialties
|
||||
if (array_key_exists('specialties', $data) && is_array($data['specialties'])) {
|
||||
$doctor->getSpecialties()->clear();
|
||||
|
||||
@@ -58,6 +58,9 @@ class Doctor
|
||||
#[ORM\Column(type: 'json', nullable: true)]
|
||||
private ?array $images = null;
|
||||
|
||||
#[ORM\Column(name: 'social_media', type: 'json', nullable: true)]
|
||||
private ?array $socialMedia = null;
|
||||
|
||||
#[ORM\Column(name: 'doctor_rate', type: 'float')]
|
||||
private float $doctorRate = 3.5;
|
||||
|
||||
@@ -139,6 +142,7 @@ class Doctor
|
||||
public function getDegree(): ?string { return $this->degree; }
|
||||
public function getInfo(): ?string { return $this->info; }
|
||||
public function getImages(): ?array { return $this->images; }
|
||||
public function getSocialMedia(): ?array { return $this->socialMedia; }
|
||||
public function getDoctorRate(): float { return $this->doctorRate; }
|
||||
public function getDoctorRatePercentage(): float { return $this->doctorRatePercentage; }
|
||||
public function isActiveDoctorAppointment(): bool { return $this->activeDoctorAppointment; }
|
||||
@@ -160,6 +164,7 @@ class Doctor
|
||||
public function setDegree(?string $v): self { $this->degree = $v; $this->touch(); return $this; }
|
||||
public function setInfo(?string $v): self { $this->info = $v; $this->touch(); return $this; }
|
||||
public function setImages(?array $v): self { $this->images = $v; $this->touch(); return $this; }
|
||||
public function setSocialMedia(?array $v): self { $this->socialMedia = $v; $this->touch(); return $this; }
|
||||
public function setDoctorRate(float $v): self { $this->doctorRate = $v; $this->touch(); return $this; }
|
||||
public function setDoctorRatePercentage(float $v): self { $this->doctorRatePercentage = $v; $this->touch(); return $this; }
|
||||
public function setActiveDoctorAppointment(bool $v): self { $this->activeDoctorAppointment = $v; $this->touch(); return $this; }
|
||||
@@ -288,6 +293,7 @@ class Doctor
|
||||
], $this->specialties->toArray()),
|
||||
'active' => $this->activeDoctorAppointment && $sf['has_schedule'],
|
||||
'img' => $this->images ?? [],
|
||||
'social_media' => $this->socialMedia,
|
||||
'expertise' => array_map(fn(DoctorService $ds) => [
|
||||
'uuid' => $ds->getUuid(), 'id' => (string) $ds->getId(), 'name' => $ds->getName(),
|
||||
], $this->services->toArray()),
|
||||
|
||||
Reference in New Issue
Block a user