DatabaseModel
in package
This class provides a mapping between entity classes and their corresponding database tables, primary keys, and fields.
Tags
Table of Contents
- TABLES = [\App\Entity\AppointmentDurationEntity::class => ['table' => 'appointment_durations', 'primaryKey' => ['id'], 'fields' => ['id' => 'id', 'name' => 'name', 'minutes' => 'minutes']], \App\Entity\MedicalCenterEntity::class => ['table' => 'medical_centers', 'primaryKey' => ['id'], 'fields' => ['id' => 'id', 'name' => 'name', 'latitude' => 'latitude', 'longitude' => 'longitude', 'zone_name' => 'zoneName', 'created_at' => 'createdAt', 'active' => 'active']], \App\Entity\MunicipalityEntity::class => ['table' => 'municipalities', 'primaryKey' => ['id'], 'fields' => ['id' => 'id', 'name' => 'name', 'province_id' => 'provinceId', 'latitude' => 'latitude', 'longitude' => 'longitude']], \App\Entity\PostalCodeEntity::class => ['table' => 'postal_codes', 'primaryKey' => ['municipality_id', 'postal_code'], 'fields' => ['municipality_id' => 'municipalityId', 'postal_code' => 'postalCode']], \App\Entity\ProvinceEntity::class => ['table' => 'provinces', 'primaryKey' => ['id'], 'fields' => ['id' => 'id', 'name' => 'name']], \App\Entity\ScheduleEntity::class => ['table' => 'schedules', 'primaryKey' => ['id'], 'fields' => ['id' => 'id', 'medical_center_id' => 'medicalCenterId', 'appointment_duration_id' => 'appointmentDurationId', 'can_be_scheduled' => 'canBeScheduled', 'created_at' => 'createdAt', 'active' => 'active']], \App\Entity\ScheduleTimeSlotEntity::class => ['table' => 'schedule_time_slots', 'primaryKey' => ['id'], 'fields' => ['id' => 'id', 'schedule_id' => 'scheduleId', 'day' => 'day', 'start_time' => 'startTime', 'end_time' => 'endTime', 'created_at' => 'createdAt', 'active' => 'active']], \App\Entity\TimeZoneEntity::class => ['table' => 'time_zones', 'primaryKey' => ['id'], 'fields' => ['id' => 'id', 'zone_name' => 'zoneName', 'country_code' => 'countryCode', 'abbreviation' => 'abbreviation', 'time_start' => 'timeStart', 'gmt_offset' => 'gmtOffset', 'dst' => 'dst']], \App\Entity\ExceptionEntity::class => ['table' => 'exceptions', 'primaryKey' => ['id'], 'fields' => ['id' => 'id', 'date' => 'date', 'full_day' => 'fullDay', 'start_time' => 'startTime', 'end_time' => 'endTime', 'comment' => 'comment', 'created_at' => 'createdAt', 'medical_center_id' => 'medicalCenterId', 'active' => 'active']], \App\Entity\AppointmentEntity::class => ['table' => 'appointments', 'primaryKey' => ['id'], 'fields' => ['id' => 'id', 'dni' => 'dni', 'full_name' => 'fullName', 'email' => 'email', 'phone_number' => 'phoneNumber', 'schedule_time_slot_id' => 'scheduleTimeSlotId', 'appointment_start' => 'appointmentStart', 'appointment_end' => 'appointmentEnd', 'status_id' => 'statusId', 'created_at' => 'createdAt']]]
- An associative array that maps entity classes to their corresponding table information.
- getFields() : array<string|int, mixed>
- Get the field mappings of the database table associated with the given entity class.
- getPrimaryKey() : array<string|int, mixed>
- Get the primary key fields of the database table associated with the given entity class.
- getTable() : string
- Get the name of the database table associated with the given entity class.
- checkTable() : void
- Check if the provided entity class is found in the mappings.
Constants
TABLES
An associative array that maps entity classes to their corresponding table information.
private
array<string, array<string, mixed>>
TABLES
= [\App\Entity\AppointmentDurationEntity::class => ['table' => 'appointment_durations', 'primaryKey' => ['id'], 'fields' => ['id' => 'id', 'name' => 'name', 'minutes' => 'minutes']], \App\Entity\MedicalCenterEntity::class => ['table' => 'medical_centers', 'primaryKey' => ['id'], 'fields' => ['id' => 'id', 'name' => 'name', 'latitude' => 'latitude', 'longitude' => 'longitude', 'zone_name' => 'zoneName', 'created_at' => 'createdAt', 'active' => 'active']], \App\Entity\MunicipalityEntity::class => ['table' => 'municipalities', 'primaryKey' => ['id'], 'fields' => ['id' => 'id', 'name' => 'name', 'province_id' => 'provinceId', 'latitude' => 'latitude', 'longitude' => 'longitude']], \App\Entity\PostalCodeEntity::class => ['table' => 'postal_codes', 'primaryKey' => ['municipality_id', 'postal_code'], 'fields' => ['municipality_id' => 'municipalityId', 'postal_code' => 'postalCode']], \App\Entity\ProvinceEntity::class => ['table' => 'provinces', 'primaryKey' => ['id'], 'fields' => ['id' => 'id', 'name' => 'name']], \App\Entity\ScheduleEntity::class => ['table' => 'schedules', 'primaryKey' => ['id'], 'fields' => ['id' => 'id', 'medical_center_id' => 'medicalCenterId', 'appointment_duration_id' => 'appointmentDurationId', 'can_be_scheduled' => 'canBeScheduled', 'created_at' => 'createdAt', 'active' => 'active']], \App\Entity\ScheduleTimeSlotEntity::class => ['table' => 'schedule_time_slots', 'primaryKey' => ['id'], 'fields' => ['id' => 'id', 'schedule_id' => 'scheduleId', 'day' => 'day', 'start_time' => 'startTime', 'end_time' => 'endTime', 'created_at' => 'createdAt', 'active' => 'active']], \App\Entity\TimeZoneEntity::class => ['table' => 'time_zones', 'primaryKey' => ['id'], 'fields' => ['id' => 'id', 'zone_name' => 'zoneName', 'country_code' => 'countryCode', 'abbreviation' => 'abbreviation', 'time_start' => 'timeStart', 'gmt_offset' => 'gmtOffset', 'dst' => 'dst']], \App\Entity\ExceptionEntity::class => ['table' => 'exceptions', 'primaryKey' => ['id'], 'fields' => ['id' => 'id', 'date' => 'date', 'full_day' => 'fullDay', 'start_time' => 'startTime', 'end_time' => 'endTime', 'comment' => 'comment', 'created_at' => 'createdAt', 'medical_center_id' => 'medicalCenterId', 'active' => 'active']], \App\Entity\AppointmentEntity::class => ['table' => 'appointments', 'primaryKey' => ['id'], 'fields' => ['id' => 'id', 'dni' => 'dni', 'full_name' => 'fullName', 'email' => 'email', 'phone_number' => 'phoneNumber', 'schedule_time_slot_id' => 'scheduleTimeSlotId', 'appointment_start' => 'appointmentStart', 'appointment_end' => 'appointmentEnd', 'status_id' => 'statusId', 'created_at' => 'createdAt']]]
Each entry contains the 'table' name, 'primaryKey' fields, and 'fields' mapping.
Methods
getFields()
Get the field mappings of the database table associated with the given entity class.
public
static getFields(string $entityClass) : array<string|int, mixed>
Parameters
- $entityClass : string
-
The fully qualified name of the entity class.
Tags
Return values
array<string|int, mixed> —The field mappings.
getPrimaryKey()
Get the primary key fields of the database table associated with the given entity class.
public
static getPrimaryKey(string $entityClass) : array<string|int, mixed>
Parameters
- $entityClass : string
-
The fully qualified name of the entity class.
Tags
Return values
array<string|int, mixed> —The primary key fields.
getTable()
Get the name of the database table associated with the given entity class.
public
static getTable(string $entityClass) : string
Parameters
- $entityClass : string
-
The fully qualified name of the entity class.
Tags
Return values
string —The name of the database table.
checkTable()
Check if the provided entity class is found in the mappings.
private
static checkTable(string $table) : void
Parameters
- $table : string
-
The name of the entity class to check.