84 lines
No EOL
2.5 KiB
PHP
Executable file
84 lines
No EOL
2.5 KiB
PHP
Executable file
<?php
|
|
|
|
namespace App\Http\Controllers\Web;
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Category;
|
|
use App\Models\Product;
|
|
use Input;
|
|
|
|
class SiteController extends Controller
|
|
{
|
|
/**
|
|
* Create a new controller instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
}
|
|
|
|
|
|
public function index()
|
|
{
|
|
return view('web.index');
|
|
}
|
|
|
|
public function site($site, $subsite = false, $product_slug = false)
|
|
{
|
|
|
|
if($product_slug){
|
|
|
|
$category = Category::where('slug', $subsite)->where('active', true)->first();
|
|
$product = Product::where('slug', $product_slug)->where('active', true)->first();
|
|
if ($category && $product) {
|
|
|
|
$data = [
|
|
'subsite' => $subsite,
|
|
'categories' => Category::where('active', true)->orderBy('pos', 'ASC')->get(),
|
|
'product' => $product,
|
|
'p_count' => Product::where('active', true)->count(),
|
|
|
|
];
|
|
return view('web.templates.produkte-show', $data);
|
|
}
|
|
}
|
|
|
|
if($site == 'produkte'){
|
|
|
|
if($subsite || $subsite != 'alle-produkte') {
|
|
$category = Category::where('slug', $subsite)->where('active', true)->first();
|
|
if ($category) {
|
|
$data = [
|
|
'subsite' => $subsite,
|
|
'categories' => Category::where('active', true)->orderBy('pos', 'ASC')->get(),
|
|
'products' => Product::whereHas('categories', function ($query) use ($category) {
|
|
$query->where('category_id', '=', $category->id);
|
|
|
|
})->where('active', true)->orderBy('pos', 'DESC')->get(),
|
|
'p_count' => Product::where('active', true)->count(),
|
|
|
|
];
|
|
return view('web.templates.' . $site, $data);
|
|
|
|
}
|
|
}
|
|
$data = [
|
|
'subsite' => 'alle-produkte',
|
|
'categories' => Category::where('active', true)->orderBy('pos', 'ASC')->get(),
|
|
'products' => Product::where('active', true)->orderBy('pos', 'ASC')->get(),
|
|
'p_count' => Product::where('active', true)->count(),
|
|
];
|
|
return view('web.templates.'.$site, $data);
|
|
}
|
|
|
|
if($subsite){
|
|
return view('web.templates.'.$subsite);
|
|
}
|
|
|
|
return view('web.templates.'.$site);
|
|
}
|
|
|
|
|
|
} |