01 2022 Microsite Promotion

This commit is contained in:
Kevin Adametz 2022-01-18 18:30:14 +01:00
parent 3f1fb9377d
commit 38e7fd504a
39 changed files with 761 additions and 336 deletions

View file

@ -21,7 +21,7 @@ class CategoryController extends Controller
{
$data = [
'values' => Category::all(),
'values' => Category::orderBy('pos', 'ASC')->get(),
];
return view('admin.category.index', $data);
}
@ -46,42 +46,66 @@ 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'));
}
@ -157,7 +181,7 @@ class CategoryController extends Controller
return redirect(route('admin_product_category_edit', [$category->id]));
}
catch (Exception $e) {
catch (\Exception $e) {
\Session()->flash('alert-danger', "Fehler".$e);
return redirect(route('admin_product_category_edit', [$category->id]));
}