24 lines
546 B
PHP
24 lines
546 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
class ObjectController extends BaseController
|
||
|
|
{
|
||
|
|
public $model = null;
|
||
|
|
public function __construct() {
|
||
|
|
$this->model = new ObjectModel();
|
||
|
|
}
|
||
|
|
public function index()
|
||
|
|
{
|
||
|
|
// global $agent;
|
||
|
|
$objects = $this->model->getAll();
|
||
|
|
return $this->response($objects);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getOne($params) {
|
||
|
|
$object = $this->model->getOnlyOne($params);
|
||
|
|
if (empty($object)) {
|
||
|
|
http_response_code(404);
|
||
|
|
return $this->response(['message' => 'Object not found']);
|
||
|
|
} else return $this->response($object);
|
||
|
|
}
|
||
|
|
}
|