Esempio n. 1
0
 public function categories($id = null)
 {
     if ($_SERVER['REQUEST_METHOD'] == "DELETE") {
         return Category_Model::DeleteCategory($id);
     }
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         $data = json_decode(file_get_contents("php://input"), true);
         return Category_Model::CreateCategory($data);
     }
     if ($_SERVER['REQUEST_METHOD'] == "PUT") {
         $data = json_decode(file_get_contents("php://input"), true);
         return Category_Model::UpdateCategory($data, $id);
     }
     if (isset($id)) {
         return Category_Model::GetCategoryById($id);
     }
     return Category_Model::GetCategories();
 }