Skip to content
Snippets Groups Projects
Select Git revision
  • e163a09b4f711672eadce0bf067ed9d2dab5117d
  • main default protected
  • (Gagafeee)
3 results

Shop.php

Blame
  • SofianeLasri's avatar
    Sofiane Lasri authored
    e163a09b
    History
    Shop.php 1.45 KiB
    <?php
    class Shop{
        public static function getAllProducts(){
            $itemsConfig = Connexion::pdo()->query("SELECT itemConfig FROM qs_shops")->fetchAll(PDO::FETCH_ASSOC);
            
            /*
            item:
                ==: org.bukkit.inventory.ItemStack
                v: 2865
                type: WHEAT
            */
            
            $return = array();
            foreach($itemsConfig as $itemConfig){
                $item = yaml_parse($itemConfig['itemConfig']);
    
                $itemAleadyEntered = false;
                foreach($return as $checkItem){
                    if(strtolower($item['item']['type']) == $checkItem->getId()){
                        $itemAleadyEntered = true;
                    }
                }
                if(!$itemAleadyEntered){
                    $return[] = new Item($item['item']['type']);
                }
            }
            return $return;
        }
        public static function getShops($search=null){
            if(is_array($search)){
    
            }else{
                // On récupère les shops
                $shops = Connexion::pdo()->query("SELECT * FROM qs_external_cache NATURAL JOIN qs_shops")->fetchAll(PDO::FETCH_ASSOC);
                for($i=0;$i<count($shops);$i++){
                    $item = yaml_parse($shops[$i]['itemConfig']);
                    $shops[$i]['item'] = new Item(strtolower($item['item']));
                    $owner = json_decode($shops[$i]['owner'], true);
                    $shops[$i]['seller'] = new Seller($owner["owner"]);
                }
                return $shops;
            }
        }
    }