[module.category] implemented GET

This commit is contained in:
xdrm-brackets 2018-03-06 16:15:19 +01:00
parent 0a0135487f
commit c6fc6631fb
1 changed files with 18 additions and 6 deletions

View File

@ -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<int> [OPT] The category id
*
* @return categories<array> 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)];
}
}