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();
|
||||
|
||||
Reference in New Issue
Block a user