April 2026 waren Wirtschaft Feedback

This commit is contained in:
Kevin Adametz 2026-04-10 17:14:38 +02:00
parent 02f2a4c23e
commit 9ce711d6b2
167 changed files with 25278 additions and 8518 deletions

View file

@ -2,18 +2,12 @@
namespace App\Http\Controllers;
use App\Models\Category;
use App\Models\Ingredient;
use App\Models\IqImage;
use App\Models\ProductCategory;
use App\Models\ProductIngredient;
use Request;
class IngredientController extends Controller
{
public function __construct()
{
$this->middleware('copyreader');
@ -25,22 +19,24 @@ class IngredientController extends Controller
$data = [
'values' => Ingredient::all(),
];
return view('admin.ingredient.index', $data);
}
public function edit($id)
{
if($id === "new"){
$model = new Ingredient();
if ($id === 'new') {
$model = new Ingredient;
$model->active = true;
}else{
} else {
$model = Ingredient::findOrFail($id);
}
$data = [
'model' => $model,
//'trans' => array_keys(config('localization.supportedLocales')),
// 'trans' => array_keys(config('localization.supportedLocales')),
];
return view('admin.ingredient.edit', $data);
}
@ -49,30 +45,42 @@ class IngredientController extends Controller
$data = Request::all();
$data['active'] = isset($data['active']) ? true : false;
if($data['id'] === "new"){
if (isset($data['default_factor']) && $data['default_factor'] !== '') {
$data['default_factor'] = reFormatNumber($data['default_factor']) ?: 1.10;
}
if (isset($data['min_stock_alert']) && $data['min_stock_alert'] === '') {
$data['min_stock_alert'] = null;
} elseif (isset($data['min_stock_alert']) && $data['min_stock_alert'] !== null) {
$data['min_stock_alert'] = reFormatNumber($data['min_stock_alert']);
}
if (empty($data['material_quality_id'])) {
$data['material_quality_id'] = null;
}
if ($data['id'] === 'new') {
$model = Ingredient::create($data);
}else{
} else {
$model = Ingredient::find($data['id']);
$model->fill($data)->save();
}
\Session()->flash('alert-save', '1');
return redirect(route('admin_product_ingredients'));
return redirect(route('admin_product_ingredients'));
}
public function delete($id){
public function delete($id)
{
if(ProductIngredient::where('ingredient_id', $id)->count()) {
if (ProductIngredient::where('ingredient_id', $id)->count()) {
\Session()->flash('alert-error', 'Eintrag wird als Produkt-Inhaltsstoff verwendet');
return redirect(route('admin_product_ingredients'));
}
$model = Ingredient::findOrFail($id);
$model->delete();
\Session()->flash('alert-success', 'Eintrag gelöscht');
return redirect(route('admin_product_ingredients'));
}
}
}