Files
gravity/บริหารจัดการคิวนวดแผนไทย/app/Controllers/TherapistController.php
T
2026-09-16 23:20:08 +07:00

47 lines
1.4 KiB
PHP

<?php
namespace App\Controllers;
use App\Helpers\Response;
use App\Middleware\JwtAuthMiddleware;
use App\Models\Therapist;
/**
* Class TherapistController
* Therapist Workload & Roster REST API Controller
*
* @package App\Controllers
*/
class TherapistController
{
private Therapist $therapistModel;
public function __construct()
{
$this->therapistModel = new Therapist();
}
/**
* GET /api/v1/therapists - Get all therapists with profiles & workload score
*/
public function index(): void
{
JwtAuthMiddleware::handle();
$branchId = isset($_GET['branch_id']) ? (int)$_GET['branch_id'] : null;
Response::success('รายชื่อหมอนวดและสถานะภาระงาน (Workload)', $this->therapistModel->getWithProfiles($branchId));
}
/**
* PUT /api/v1/therapists/{id}/availability - Toggle Availability
*/
public function toggleAvailability(int $id): void
{
JwtAuthMiddleware::handle();
$input = json_decode(file_get_contents('php://input'), true) ?? $_POST;
$available = !empty($input['is_available']);
$this->therapistModel->setAvailability($id, $available);
Response::success('อัปเดตสถานะความพร้อมให้บริการของหมอนวดแล้ว', ['therapist_id' => $id, 'is_available' => $available ? 1 : 0]);
}
}