Slim API deployment - composer install + full CRUD endpoints

This commit is contained in:
Hermes Agent
2026-05-20 14:36:05 +02:00
parent 48bf9c7088
commit 8ab4e532fd
1727 changed files with 7746 additions and 7 deletions

View File

@@ -79,4 +79,41 @@ final class InstructorRepository extends BaseRepository
return $statement->fetch() ?: null;
}
public function findById(int $id): ?array
{
$statement = $this->db->prepare('SELECT * FROM instructors WHERE id = :id');
$statement->execute(['id' => $id]);
return $statement->fetch() ?: null;
}
public function listForTenant(int $tenantId): array
{
$statement = $this->db->prepare('SELECT * FROM instructors WHERE tenant_id = :tenant_id AND is_active = 1 ORDER BY last_name, first_name');
$statement->execute(['tenant_id' => $tenantId]);
return $statement->fetchAll();
}
public function updateSettings(int $instructorId, array $settings): bool
{
$allowed = ['max_daily_units', 'max_daily_override', 'max_weekly_units', 'max_weekly_override', 'booking_enabled'];
$sets = [];
$params = ['id' => $instructorId];
foreach ($allowed as $key) {
if (array_key_exists($key, $settings)) {
$sets[] = "{$key} = :{$key}";
$params[$key] = $settings[$key];
}
}
if (empty($sets)) {
return false;
}
$sql = 'UPDATE instructors SET ' . implode(', ', $sets) . ', updated_at = :updated_at WHERE id = :id';
$params['updated_at'] = $this->now();
$statement = $this->db->prepare($sql);
$statement->execute($params);
return (bool) $statement->rowCount();
}
}