summaryrefslogtreecommitdiff
path: root/site/app/Http/Controllers/PageFeedController.php
blob: ffe86290937c2fb76555b69255ea8623e0023309 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php                                                                                                                                                                                                                
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Helpers\CryptoHelper;

use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;

class PageFeedController 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 ";
		} 
		$query .= "(SELECT spirit_type as name, image_url, spirit_type, spirit_type AS url, CONCAT(spirit_type,'-Feed') AS feedname, CONCAT('Zum ', spirit_type, '-Feed') AS linktext FROM ". $view ."_view WHERE original_price > 19.98 AND shop != 'Drankdozijn' ORDER BY created_at DESC LIMIT 1)";
	    }

	    # query mit festen parametern
		$query .= " UNION (SELECT 'Alle Angebote' as name, '/img/paw-400-400.png' as image_url, 'Alle Angebote' as spirit_type, 'all' AS url, 'Feed aller Angebote' AS feedname, 'Zum Feed aller Angebote' AS linktext FROM all_view LIMIT 1)";

	    $data = DB::select($query);
	    
	    array_push($views, "alle angebote");

        return view('feeds', ['data' => $data, 'views' => $views]);
    }
}