39 lines
693 B
PHP
39 lines
693 B
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: lucas
|
|
* Date: 01/03/18
|
|
* Time: 16:43
|
|
*/
|
|
|
|
namespace api\module;
|
|
|
|
|
|
use database\core\Repo;
|
|
use database\repo\category;
|
|
|
|
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){
|
|
$cat_id = null;
|
|
extract($args);
|
|
|
|
/** @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];
|
|
|
|
}
|
|
|
|
} |