format("Y-m-d"); } public static function contains($array, $str) { foreach($array as $item) { if ( str_contains(strtolower($str), strtolower($item) ) ) { return true; } } return false; } public static function getAngeboteData() { $views = array("whisky", "wodka", "gin", "rum", "misc"); $query = ""; foreach($views as $view) { if ($query != "") { $query .= " UNION "; } $query .= " (SELECT name, image_url, spirit_type, spirit_type AS url, spirit_type AS angebotsname, (SELECT MAX(procent) FROM " . $view . "_view) as procent, '' AS linktext FROM ". $view ."_view WHERE original_price > 29.98 AND spirit_type != 'Verschiedenes' AND shop != 'Rum & Co' AND shop = 'Drankdozijn' ORDER BY created_at DESC, procent DESC LIMIT 1)"; } $data = DB::select($query); return $data; } public static function getAngeboteCount() { return DB::select("SELECT count(*) as count FROM all_view")[0]; } public static function getCocktailCount() { $cocktails = new Cocktail; return $cocktails->count(); } public static function fillCache(){ Cache::put('angebote_count', Helper::getAngeboteCount(), 6000); // 100 minutes Cache::put('cocktail_count', Helper::getCocktailCount(), 6000); // 100 minutes Cache::put('angebote_index', Helper::getAngeboteData(), 6000); // 100 minutes } }