Joywork/presentation-api/Controllers/ComplexesController.php
2026-05-22 21:21:54 +03:00

37 lines
1.1 KiB
PHP

<?php
class ComplexesController extends BaseController {
public $model = null;
public function __construct() {
$this->model = new ComplexesModel();
}
public function getComplexes($id) {
// Валидация и санитизация входных данных
if (!is_array($id)) {
return $this->response(['error' => 'Invalid ID'], 400);
}
$params = $id;
$catalog = $this->model->getComplexes($params);
return $this->response($catalog);
}
public function getApartment($id) {
// Валидация и санитизация входных данных
if (!is_array($id)) {
return $this->response(['error' => 'Invalid ID'], 400);
}
$token = isset($_GET['token']) ? filter_var($_GET['token'], FILTER_SANITIZE_STRING) : null;
if (!$token) {
return $this->response(['error' => 'Token is required'], 400);
}
$apartment = $this->model->getApartment($id, $token);
return $this->response($apartment);
}
}