2017-12-10 19:34:49 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace api\module;
|
|
|
|
|
|
|
|
use \error\core\Error;
|
2017-12-10 21:33:23 +00:00
|
|
|
use \database\core\Repo;
|
2017-12-10 19:34:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
class admin{
|
|
|
|
|
|
|
|
|
2017-12-10 21:33:23 +00:00
|
|
|
/* (1) Return an admin data
|
|
|
|
*
|
|
|
|
* @id_admin<id> [OPT] UID de l'administrateur
|
|
|
|
*
|
|
|
|
* @return data<Array> Administrateurs correspondants
|
|
|
|
*
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
public static function get($args){
|
2017-12-10 19:34:49 +00:00
|
|
|
extract($args);
|
|
|
|
|
2017-12-10 21:33:23 +00:00
|
|
|
/* (1) If @id_admin is set -> get by id
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
if( is_numeric($id_admin) ){
|
|
|
|
|
|
|
|
/* (1) Search admin by id */
|
|
|
|
$fetch_admin = Repo::request('admin', 'getById', $id_admin);
|
|
|
|
|
|
|
|
/* (2) If not found -> return empty data */
|
|
|
|
if( !$fetch_admin )
|
|
|
|
return [ 'data' => [] ];
|
|
|
|
|
|
|
|
/* (3) Return fetched admin */
|
|
|
|
return [ 'data' => [$fetch_admin] ];
|
|
|
|
|
|
|
|
|
|
|
|
/* (2) Else -> get all
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
}else
|
|
|
|
return [ 'data' => Repo::request('admin', 'getAll') ];
|
2017-12-10 19:34:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|