Cookiebot / Pixel / Kategorien erweitern
This commit is contained in:
parent
36872100c6
commit
7d1ee844eb
28 changed files with 464 additions and 246 deletions
|
|
@ -5,7 +5,7 @@ namespace App\Http\Controllers;
|
|||
use App\Models\Category;
|
||||
use App\Models\IqImage;
|
||||
use App\Models\ProductCategory;
|
||||
use\Request;
|
||||
use Request;
|
||||
|
||||
|
||||
class CategoryController extends Controller
|
||||
|
|
@ -21,7 +21,7 @@ class CategoryController extends Controller
|
|||
{
|
||||
|
||||
$data = [
|
||||
'values' => Category::all(),
|
||||
'values' => Category::orderBy('pos', 'DESC')->get(),
|
||||
];
|
||||
return view('admin.category.index', $data);
|
||||
}
|
||||
|
|
@ -46,59 +46,93 @@ class CategoryController extends Controller
|
|||
{
|
||||
|
||||
$data = Request::all();
|
||||
$data['active'] = isset($data['active']) ? true : false;
|
||||
$data['parent_id'] = isset($data['parent_id']) ? $data['parent_id'] : null;
|
||||
if($data['id'] == "new"){
|
||||
$model = Category::create($data);
|
||||
}else{
|
||||
$model = Category::find($data['id']);
|
||||
$model->fill($data)->save();
|
||||
if($data['action'] === 'save-product_category'){
|
||||
|
||||
if($data['id'] === 'new'){
|
||||
$ProductCategory = ProductCategory::create([
|
||||
'pos' => $data['pos'],
|
||||
'product_id' => $data['product_id'],
|
||||
'category_id' => $data['category_id'],
|
||||
]);
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_product_category_edit', [$ProductCategory->category_id]));
|
||||
}else{
|
||||
$ProductCategory = ProductCategory::findOrFail($data['id']);
|
||||
if($ProductCategory->category_id != $data['category_id']){
|
||||
abort(404);
|
||||
}
|
||||
$ProductCategory->pos = $data['pos'];
|
||||
$ProductCategory->product_id = $data['product_id'];
|
||||
$ProductCategory->save();
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_product_category_edit', [$ProductCategory->category_id]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$trans = [];
|
||||
if(!empty($data['trans_name'])){
|
||||
|
||||
foreach ($data['trans_name'] as $lang => $value){
|
||||
if($value && $value != null){
|
||||
$trans[$lang] = $value;
|
||||
if($data['action'] === 'save-form'){
|
||||
$data['active'] = isset($data['active']) ? true : false;
|
||||
$data['parent_id'] = isset($data['parent_id']) ? $data['parent_id'] : null;
|
||||
if($data['id'] == "new"){
|
||||
$model = Category::create($data);
|
||||
}else{
|
||||
$model = Category::find($data['id']);
|
||||
$model->fill($data)->save();
|
||||
}
|
||||
|
||||
$trans = [];
|
||||
if(!empty($data['trans_name'])){
|
||||
|
||||
foreach ($data['trans_name'] as $lang => $value){
|
||||
if($value && $value != null){
|
||||
$trans[$lang] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$model->trans_name = $trans;
|
||||
$model->save();
|
||||
|
||||
$trans = [];
|
||||
if(!empty($data['trans_headline'])){
|
||||
foreach ($data['trans_headline'] as $lang => $value){
|
||||
if($value && $value != null){
|
||||
$trans[$lang] = $value;
|
||||
$model->trans_name = $trans;
|
||||
$model->save();
|
||||
|
||||
$trans = [];
|
||||
if(!empty($data['trans_headline'])){
|
||||
foreach ($data['trans_headline'] as $lang => $value){
|
||||
if($value && $value != null){
|
||||
$trans[$lang] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
$model->trans_headline = $trans;
|
||||
$model->save();
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_product_categories'));
|
||||
}
|
||||
$model->trans_headline = $trans;
|
||||
$model->save();
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_product_categories'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function delete($id){
|
||||
public function delete($do, $id){
|
||||
|
||||
if(ProductCategory::where('category_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Eintrag wird als Produkt-Kategorie verwendet');
|
||||
if($do === 'product_category'){
|
||||
$model = ProductCategory::findOrFail($id);
|
||||
$category = $model->category;
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect(route('admin_product_category_edit', [$category->id]));
|
||||
}
|
||||
if($do === 'category'){
|
||||
if(ProductCategory::where('category_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Eintrag hat noch Produkte, erst löschen');
|
||||
return redirect(route('admin_product_categories'));
|
||||
}
|
||||
if(Category::where('parent_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Eintrag wird als Haup-Kategorie verwendet');
|
||||
return redirect(route('admin_product_categories'));
|
||||
}
|
||||
$model = Category::findOrFail($id);
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect(route('admin_product_categories'));
|
||||
}
|
||||
if(Category::where('parent_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Eintrag wird als Haup-Kategorie verwendet');
|
||||
return redirect(route('admin_product_categories'));
|
||||
}
|
||||
$model = Category::findOrFail($id);
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect(route('admin_product_categories'));
|
||||
|
||||
}
|
||||
|
||||
// Upload FILE -----------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ class HomeController extends Controller
|
|||
if(!Auth::check()){
|
||||
return redirect('login');
|
||||
}
|
||||
|
||||
$data = [
|
||||
'user' => Auth::user(),
|
||||
'now' => Carbon::now(),
|
||||
|
|
@ -49,12 +50,12 @@ class HomeController extends Controller
|
|||
|
||||
$data = Request::get('data');
|
||||
$target = Request::get('target');
|
||||
|
||||
$response = "";
|
||||
if($data === "data_protection"){
|
||||
$data = [
|
||||
'modal' => true,
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'user_shop' => true,
|
||||
'isMivitaShop' => false,
|
||||
];
|
||||
$response = view('legal.data_protect_de', $data)->render();
|
||||
}
|
||||
|
|
@ -133,6 +134,7 @@ class HomeController extends Controller
|
|||
$data = [
|
||||
'modal' => false,
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'isMivitaShop' => Util::isMivitaShop(),
|
||||
];
|
||||
return view('legal.data_protected', $data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ class ProductController extends Controller
|
|||
}else{
|
||||
$model = Product::findOrFail($id);
|
||||
}
|
||||
|
||||
$country_for_prices = Country::where('own_eur', '=', true)->orWhere('currency', '=', true)->get();
|
||||
$data = [
|
||||
'product' => $model,
|
||||
|
|
@ -59,7 +58,6 @@ class ProductController extends Controller
|
|||
|
||||
public function store()
|
||||
{
|
||||
|
||||
$data = Request::all();
|
||||
|
||||
$rules = array(
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
|
|||
use App\Models\Category;
|
||||
use App\Models\IqSite;
|
||||
use App\Models\Product;
|
||||
use App\Models\ProductCategory;
|
||||
use App\Services\Util;
|
||||
|
||||
class SiteController extends Controller
|
||||
|
|
@ -41,7 +42,6 @@ class SiteController extends Controller
|
|||
}
|
||||
public function site($site, $subsite = false, $product_slug = false)
|
||||
{
|
||||
|
||||
$subsite = trim($subsite, '/');
|
||||
$product_slug = trim($product_slug, '/');
|
||||
if($product_slug){
|
||||
|
|
@ -71,13 +71,18 @@ class SiteController extends Controller
|
|||
$headline_image = $category->iq_image;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$product_categories = ProductCategory::where('category_id', $category->id)->whereHas('product', function ($query) use ($category) {
|
||||
$query->where('active', true)->where('show_at', '<=', 1);
|
||||
})->orderBy('pos', 'DESC')->get();
|
||||
|
||||
$data = [
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'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)->where('show_at', '<=', 1)->orderBy('pos', 'DESC')->get(),
|
||||
'categories' => Category::where('active', true)->orderBy('pos', 'DESC')->get(),
|
||||
'products' => false,
|
||||
'product_categories' => $product_categories,
|
||||
'p_count' => Product::where('active', true)->where('show_at', '<=', 1)->count(),
|
||||
'headline' => $category->getLang('headline'),
|
||||
'headline_image' => $headline_image,
|
||||
|
|
@ -89,8 +94,9 @@ class SiteController extends Controller
|
|||
$data = [
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'subsite' => 'alle-produkte',
|
||||
'categories' => Category::where('active', true)->orderBy('pos', 'ASC')->get(),
|
||||
'products' => Product::where('active', true)->where('show_at', '<=', 1)->orderBy('pos', 'ASC')->get(),
|
||||
'categories' => Category::where('active', true)->orderBy('pos', 'DESC')->get(),
|
||||
'products' => Product::where('active', true)->where('show_at', '<=', 1)->orderBy('pos', 'DESC')->get(),
|
||||
'product_categories' => false,
|
||||
'p_count' => Product::where('active', true)->where('show_at', '<=', 1)->count(),
|
||||
'headline' => 'Produktwelt',
|
||||
'headline_image' => false,
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ class Subdomain
|
|||
}
|
||||
\Session::put('user_shop', $user_shop);
|
||||
\Session::put('user_shop_domain', config('app.protocol').$user_shop->slug.".".config('app.domain').config('app.tld_care'));
|
||||
|
||||
Config::set('app.url', $user_shop->slug.".".config('app.domain').config('app.tld_care'));
|
||||
return $next($request);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class Category extends Model
|
|||
|
||||
public function product_categories()
|
||||
{
|
||||
return $this->hasMany('App\Models\ProductCategory', 'category_id', 'id');
|
||||
return $this->hasMany('App\Models\ProductCategory', 'category_id', 'id')->orderBy('pos', 'DESC');
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ class Product extends Model
|
|||
}
|
||||
|
||||
public function categories(){
|
||||
return $this->hasMany('App\Models\ProductCategory', 'product_id', 'id');
|
||||
return $this->hasMany('App\Models\ProductCategory', 'product_id', 'id')->orderBy('pos', 'DESC');
|
||||
}
|
||||
|
||||
public function images(){
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class ProductCategory extends Model
|
|||
protected $table = 'product_categories';
|
||||
|
||||
protected $fillable = [
|
||||
'product_id', 'category_id',
|
||||
'product_id', 'category_id', 'pos'
|
||||
];
|
||||
|
||||
public function product()
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ class HTMLHelper
|
|||
}
|
||||
|
||||
public static function getCategoriesOptions($ids = array(), $all = true){
|
||||
$values = Category::where('active', 1)->get();
|
||||
$values = Category::where('active', 1)->orderBy('pos', 'DESC')->get();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret .= '<option value="">'.__('no').'</option>\n';
|
||||
|
|
|
|||
|
|
@ -228,6 +228,12 @@ class Util
|
|||
}
|
||||
return url($uri);
|
||||
}
|
||||
|
||||
public static function isMivitaShop(){
|
||||
return \Config::get('app.url') === config('app.domain').config('app.tld_shop');
|
||||
}
|
||||
|
||||
|
||||
public static function sanitize($string, $force_lowercase = true, $anal = false, $substr = false)
|
||||
{
|
||||
$strip = array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue