namespace App\Repositories; use PDO; class AvailabilityRepository extends BaseRepository { protected $table_name = "doctor_availabilities"; public function __construct(PDO $db) { parent::__construct($db); } public function findByDoctorIdAndDate(int $doctorId, string $date): array { $query = "SELECT * FROM " . $this->table_name . " WHERE doctor_id = ? AND availability_date = ? ORDER BY start_time ASC"; $stmt = $this->db->prepare($query); $stmt->bindParam(1, $doctorId); $stmt->bindParam(2, $date); $stmt->execute(); return $stmt->fetchAll(PDO::FETCH_ASSOC); } public function findAvailableSlots(int $doctorId, string $date): array { // Bu metot, belirli bir doktorun belirli bir tarihteki boş randevu slotlarını bulmak için kullanılabilir. // Daha karmaşık bir sorgu gerektirebilir (örneğin, mevcut randevuları dışlamak). $query = "SELECT * FROM " . $this->table_name . " WHERE doctor_id = ? AND availability_date = ? AND is_booked = 0 ORDER BY start_time ASC"; $stmt = $this->db->prepare($query); $stmt->bindParam(1, $doctorId); $stmt->bindParam(2, $date); $stmt->execute(); return $stmt->fetchAll(PDO::FETCH_ASSOC); } }