feat(api): add dashboard endpoints for clinic, doctor, and secretary roles
- Implemented GET /api/v1/dashboard/clinic to return clinic stats and today's schedule for clinic owners. - Implemented GET /api/v1/dashboard/doctor to return doctor's stats and today's schedule for doctors. - Implemented GET /api/v1/dashboard/secretary to return stats and conditional appointments for secretaries. feat(migrations): create user_active_context and mobile_verification_otp tables - Added migration to create user_active_context table for tracking active user sessions. - Added migration to create mobile_verification_otp table for handling mobile number verification. feat(migrations): create site_config table for application settings - Added migration to create site_config table to store various site configuration settings. feat(appointments): create MyAppointmentsController for user-specific appointments - Added MyAppointmentsController to handle fetching user-specific appointments with pagination and filtering. feat(auth): implement NotificationMobileController for mobile number verification - Added NotificationMobileController to handle OTP requests and verification for mobile number changes. feat(auth): create MobileVerificationOtp entity for OTP management - Created MobileVerificationOtp entity to manage OTP records for mobile verification. feat(auth): create UserActiveContext entity for user session management - Created UserActiveContext entity to manage user active sessions. feat(config): implement SiteConfigController for managing site settings - Added SiteConfigController to handle fetching and updating site configuration settings. feat(config): create SiteConfig entity and repository for configuration management - Created SiteConfig entity and repository to manage site configuration data.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Config\Controller;
|
||||
|
||||
use App\Config\Repository\SiteConfigRepository;
|
||||
use App\Shared\Controller\BaseController;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
class SiteConfigController extends BaseController
|
||||
{
|
||||
private const ALLOWED_KEYS = [
|
||||
'commission_enabled',
|
||||
'commission_percent',
|
||||
'site_name',
|
||||
'support_phone',
|
||||
'max_cancel_hours_before',
|
||||
'appointment_reminder_hours',
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
private readonly SiteConfigRepository $configRepo,
|
||||
private readonly EntityManagerInterface $em,
|
||||
) {}
|
||||
|
||||
#[Route('/api/v1/admin/settings', methods: ['GET'])]
|
||||
public function get(): JsonResponse
|
||||
{
|
||||
return $this->success($this->configRepo->getAll());
|
||||
}
|
||||
|
||||
#[Route('/api/v1/admin/settings', methods: ['PATCH'])]
|
||||
public function patch(Request $request): JsonResponse
|
||||
{
|
||||
$data = json_decode($request->getContent(), true) ?? [];
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if (!in_array($key, self::ALLOWED_KEYS, true)) {
|
||||
continue;
|
||||
}
|
||||
$this->configRepo->set($key, $value === null ? null : (string) $value);
|
||||
}
|
||||
|
||||
$this->em->flush();
|
||||
|
||||
return $this->success($this->configRepo->getAll());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Config\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'site_config')]
|
||||
class SiteConfig
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(name: 'config_key', type: 'string', length: 100)]
|
||||
private string $configKey;
|
||||
|
||||
#[ORM\Column(name: 'config_value', type: 'text', nullable: true)]
|
||||
private ?string $configValue;
|
||||
|
||||
#[ORM\Column(name: 'updated_at', type: 'integer')]
|
||||
private int $updatedAt;
|
||||
|
||||
public function __construct(string $key, ?string $value = null)
|
||||
{
|
||||
$this->configKey = $key;
|
||||
$this->configValue = $value;
|
||||
$this->updatedAt = time();
|
||||
}
|
||||
|
||||
public function getKey(): string { return $this->configKey; }
|
||||
public function getValue(): ?string { return $this->configValue; }
|
||||
|
||||
public function setValue(?string $value): self
|
||||
{
|
||||
$this->configValue = $value;
|
||||
$this->updatedAt = time();
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Config\Repository;
|
||||
|
||||
use App\Config\Entity\SiteConfig;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
class SiteConfigRepository extends ServiceEntityRepository
|
||||
{
|
||||
// Default values returned when a key is missing from DB
|
||||
private const DEFAULTS = [
|
||||
'commission_enabled' => '0',
|
||||
'commission_percent' => '0',
|
||||
'site_name' => 'ClinicPro',
|
||||
'support_phone' => '',
|
||||
'max_cancel_hours_before' => '24',
|
||||
'appointment_reminder_hours' => '2',
|
||||
];
|
||||
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, SiteConfig::class);
|
||||
}
|
||||
|
||||
public function get(string $key): ?string
|
||||
{
|
||||
$row = $this->find($key);
|
||||
if ($row !== null) {
|
||||
return $row->getValue();
|
||||
}
|
||||
return self::DEFAULTS[$key] ?? null;
|
||||
}
|
||||
|
||||
public function getAll(): array
|
||||
{
|
||||
$rows = $this->findAll();
|
||||
$map = [];
|
||||
foreach ($rows as $row) {
|
||||
$map[$row->getKey()] = $row->getValue();
|
||||
}
|
||||
// Fill missing keys with defaults
|
||||
foreach (self::DEFAULTS as $key => $default) {
|
||||
if (!isset($map[$key])) {
|
||||
$map[$key] = $default;
|
||||
}
|
||||
}
|
||||
return $map;
|
||||
}
|
||||
|
||||
public function set(string $key, ?string $value): void
|
||||
{
|
||||
$row = $this->find($key);
|
||||
if ($row === null) {
|
||||
$row = new SiteConfig($key, $value);
|
||||
$this->getEntityManager()->persist($row);
|
||||
} else {
|
||||
$row->setValue($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user