summaryrefslogtreecommitdiff
path: root/site/app/Http/Controllers/FKIndexController.php
diff options
context:
space:
mode:
Diffstat (limited to 'site/app/Http/Controllers/FKIndexController.php')
-rw-r--r--site/app/Http/Controllers/FKIndexController.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/site/app/Http/Controllers/FKIndexController.php b/site/app/Http/Controllers/FKIndexController.php
new file mode 100644
index 0000000..92e6866
--- /dev/null
+++ b/site/app/Http/Controllers/FKIndexController.php
@@ -0,0 +1,40 @@
+<?php
+namespace App\Http\Controllers;
+use Illuminate\Http\Request;
+use App\Helpers\CryptoHelper;
+
+use Illuminate\Support\Facades\DB;
+use App\Http\Controllers\Controller;
+
+class FKIndexController extends Controller {
+ /**
+ * Shows the index page.
+ *
+ * @return Response
+ */
+ public function showPage(Request $request) {
+
+
+ $views = array("whisky", "wodka", "gin", "rum", "misc");
+ $query = "";
+
+ foreach($views as $view) {
+ if ($query != "") {
+ $query .= " UNION ";
+ }
+ # subquery to get procent, because cheap spirits don't look good
+ #$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 > 19.98 AND shop != \"Drankdozijn\" ORDER BY procent DESC LIMIT 1)";
+ $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 > 19.98 ORDER BY procent DESC LIMIT 1)";
+ }
+ $query .= " UNION (SELECT 'Alle Angebote' as name, 'https://angebote.fuselkoenig.de/img/feed-icon-gray.jpg' as image_url, 'RSS-Feeds' as spirit_type, 'feeds' AS url, 'RSS-Feeds' AS angebotsname, (SELECT MAX(procent) FROM all_view) as procent, 'Zu den RSS-Feeds' AS linktext FROM all_view LIMIT 1)";
+
+ $data = DB::select($query);
+
+ $count = DB::select("SELECT count(*) as count FROM all_view")[0];
+ #$data = DB::table('whisky_view')->orderBy('procent', 'DESC')->limit(100)->simplePaginate(20);
+
+ #$views[] = "rss-feeds";
+
+ return view('fk-index', ['data' => $data, 'views' => $views, 'hits' => $count]);
+ }
+}