From 0393733bcd3f222c1e1a5c1711b5b4ef81ce7733 Mon Sep 17 00:00:00 2001 From: Mathieu Sanchez Date: Thu, 13 Dec 2018 11:05:57 +0900 Subject: [PATCH] Example for API --- src/API/APIUser.php | 19 +++++++++++++------ src/Model/BDTables.php | 4 ++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/API/APIUser.php b/src/API/APIUser.php index 4f37fed..e85a0b4 100644 --- a/src/API/APIUser.php +++ b/src/API/APIUser.php @@ -2,16 +2,19 @@ namespace WebProjectFitness\API; +use WebProjectFitness\Model\BDTables; +use WebProjectFitness\Model\Model; + class APIUser extends API { private $declaredFunctions = [ 'create' => [ - 'method' => 'POST', + 'method' => 'GET', 'params' => [ - 'id' => [ - 'required' => true, - 'type' => 'string' - ] +// 'id' => [ +// 'required' => true, +// 'type' => 'string' +// ] ] ] ]; @@ -21,7 +24,11 @@ class APIUser extends API { } public function create( $data ) { - $this->returnJson( [ 'body' => 'truc', 'id' => $data[ 'id' ] ] ); + Model::insert( BDTables::USER, [ + "name" => "Mathi", + "user_id" => "bite" + ] ); + $this->returnJson( [ 'body' => 'truc' ] ); } } \ No newline at end of file diff --git a/src/Model/BDTables.php b/src/Model/BDTables.php index 620daf8..a13e582 100644 --- a/src/Model/BDTables.php +++ b/src/Model/BDTables.php @@ -8,6 +8,10 @@ abstract class BDTables { // Ex : const ABONNEMENT = 'abonnement'; const LOGS = "logs"; + const USER = "user"; + const FAVORITE = "favorite"; + const EXERCISE = "exercise"; + const TRAINING = "training"; } ?> \ No newline at end of file