[OPT] UID de l'administrateur * * @return data Administrateurs correspondants * ---------------------------------------------------------*/ public static function get($args){ extract($args); /* (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') ]; } /* (2) Creates a new administrator * * @username Identifiant de l'administrateur * @mail Adresse mail de l'administrateur * @password Mot de passe de l'administrateur * * @return id_admin UID de l'administrateur crée * ---------------------------------------------------------*/ public static function post($args){ extract($args); /* (1) Création admin */ $id_created = Repo::request('admin', 'create', $username, $mail, $password); /* (2) Gestion erreur */ if( $id_created === false ) return [ 'error' => new Error(Err::RepoError) ]; /* (3) Renvoi @id_admin */ return [ 'id_admin' => $id_created ]; } }