17 Nov - Static Sites to laravel
This commit is contained in:
parent
610aa1e202
commit
5ff57a21a7
3661 changed files with 569001 additions and 771 deletions
86
app/Http/Controllers/Web/SiteController.php
Executable file
86
app/Http/Controllers/Web/SiteController.php
Executable file
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Category;
|
||||
use App\Models\Product;
|
||||
use Carbon\Carbon;
|
||||
use Request;
|
||||
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', 'DESC')->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', 'DESC')->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', 'DESC')->get(),
|
||||
'products' => Product::where('active', true)->orderBy('pos', 'DESC')->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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue