Joywork/presentation-api/Controllers/CatalogController.php

36 lines
999 B
PHP
Raw Normal View History

2026-05-22 20:21:54 +02:00
<?php
class CatalogController extends BaseController {
public $model = null;
public function __construct() {
$this->model = new CatalogModel();
}
public function getCatalog($id) {
if (!is_array($id)) {
return $this->response(['error' => 'Invalid ID'], 400);
}
$params = $id;
$catalog = $this->model->getCatalog($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);
}
}