36 lines
999 B
PHP
36 lines
999 B
PHP
<?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);
|
|
}
|
|
} |