diff --git a/build/api/module/categoryController.php b/build/api/module/categoryController.php index 8335bcf..12e2033 100644 --- a/build/api/module/categoryController.php +++ b/build/api/module/categoryController.php @@ -10,18 +10,30 @@ namespace api\module; use database\core\Repo; +use database\repo\category; -class categoryController -{ +class categoryController{ + /* (1) Returns 1 or all categories + * + * @cat_id [OPT] The category id + * + * @return categories The categorie(s) data + * + ---------------------------------------------------------*/ public function get($args){ - $idCat = 0; + $cat_id = null; extract($args); - /** @var \database\repo\category $repo */ - $repo = Repo::getRepo("category"); + /** @var category $cat_repo */ + $cat_repo = Repo::getRepo('category'); + + /* (1) Get All categories or 1 by its id (if set) */ + $fetched = $cat_repo->get($cat_id); + + /* (2) Return data */ + return ['categories' => $fetched]; - return ["data" => $repo->getStats($idCat)]; } } \ No newline at end of file