<?php require_once "../Model/Database.php"; require_once "../Model/Food.php"; require_once "../Model/FoodDB.php"; $foods = FoodDB::getAll(); echo $foods;
public static function getHistory($count) { $foods = json_decode(FoodDB::getAll()); $time = array(); $t = time(); foreach ($foods as $food) { if (isset($_COOKIE[$food->Food_id]) && $_COOKIE[$food->Food_id] >= strtotime('-7 day', $t)) { $time[$food->Food_id] = $_COOKIE[$food->Food_id]; } } arsort($time); $results = array(); foreach ($time as $key => $item) { $food = FoodDB::getFoodById($key); $results[] = $food; if (count($results) >= $count) { break; } } return $results; }