13-05-2026 Waren Wirtschaft

This commit is contained in:
Kevin Adametz 2026-05-13 18:09:20 +02:00
parent 9ce711d6b2
commit ca3eb663fe
40 changed files with 1000 additions and 189 deletions

View file

@ -27,7 +27,7 @@ class PackagingItemController extends Controller
->orderBy('name');
if ($isShipping) {
$query->whereIn('category', ['shipping', 'label', 'shipping_office']);
$query->where('category', 'shipping');
} else {
$query->where('category', 'packaging');
}
@ -41,7 +41,10 @@ class PackagingItemController extends Controller
public function create(Request $request)
{
$category = $request->get('category', 'packaging');
$category = $request->query('category', 'packaging');
if (! in_array($category, ['packaging', 'shipping'], true)) {
$category = 'packaging';
}
return view('admin.inventory.packaging-items.form', [
'model' => new PackagingItem(['active' => true, 'category' => $category === 'shipping' ? 'shipping' : 'packaging', 'weight_grams' => 0]),
@ -53,18 +56,27 @@ class PackagingItemController extends Controller
public function store(StorePackagingItemRequest $request)
{
$item = $this->packagingItemRepository->create($request->validated());
$validated = $request->validated();
\Log::debug('PackagingItem STORE raw input', [
'category_raw' => $request->input('category'),
'category_hex' => bin2hex((string) $request->input('category')),
'all_input' => $request->all(),
]);
\Log::debug('PackagingItem STORE validated', $validated);
$item = $this->packagingItemRepository->create($validated);
\Session::flash('alert-save', '1');
$category = in_array($item->category, ['shipping', 'label', 'shipping_office']) ? 'shipping' : 'packaging';
$category = $item->category === 'shipping' ? 'shipping' : 'packaging';
return redirect()->route('admin.inventory.packaging-items.index', ['category' => $category]);
}
public function edit(PackagingItem $packagingItem)
{
$category = in_array($packagingItem->category, ['shipping', 'label', 'shipping_office']) ? 'shipping' : 'packaging';
$category = $packagingItem->category === 'shipping' ? 'shipping' : 'packaging';
return view('admin.inventory.packaging-items.form', [
'model' => $packagingItem,
@ -76,18 +88,27 @@ class PackagingItemController extends Controller
public function update(UpdatePackagingItemRequest $request, PackagingItem $packagingItem)
{
$this->packagingItemRepository->update($packagingItem, $request->validated());
$validated = $request->validated();
\Log::debug('PackagingItem UPDATE raw input', [
'category_raw' => $request->input('category'),
'category_hex' => bin2hex((string) $request->input('category')),
'all_input' => $request->all(),
]);
\Log::debug('PackagingItem UPDATE validated', $validated);
$this->packagingItemRepository->update($packagingItem, $validated);
\Session::flash('alert-save', '1');
$category = in_array($packagingItem->category, ['shipping', 'label', 'shipping_office']) ? 'shipping' : 'packaging';
$category = $packagingItem->category === 'shipping' ? 'shipping' : 'packaging';
return redirect()->route('admin.inventory.packaging-items.index', ['category' => $category]);
}
public function destroy(PackagingItem $packagingItem)
{
$category = in_array($packagingItem->category, ['shipping', 'label', 'shipping_office']) ? 'shipping' : 'packaging';
$category = $packagingItem->category === 'shipping' ? 'shipping' : 'packaging';
$packagingItem->delete();

View file

@ -190,8 +190,7 @@ class StockEntryController extends Controller
$categoryMap = [
'packaging' => 'packaging',
'label' => 'label',
'shipping_office' => 'shipping_office',
'shipping' => 'shipping',
];
$query = PackagingItem::query()
@ -223,11 +222,11 @@ class StockEntryController extends Controller
return [
'suppliers' => Supplier::query()->where('active', true)->orderBy('name')->get(),
'locations' => Location::query()->where('active', true)->orderBy('name')->get(),
'materialQualities' => MaterialQuality::query()->orderBy('pos')->orderBy('name')->get(),
'entryTypeLabels' => [
'ingredient' => __('Rohstoff'),
'packaging' => __('Verpackung'),
'label' => __('Etikett'),
'shipping_office' => __('Versand & Büro'),
'packaging' => __('Produktverpackung'),
'shipping' => __('Versandverpackung'),
],
];
}

View file

@ -108,10 +108,6 @@ class ProductController extends Controller
return redirect(route('admin_product_edit', [$product->id]));
}
\Session()->flash('alert-save', '1');
return redirect(route('admin_product_show'));
}
public function copy($id)
@ -135,16 +131,16 @@ class ProductController extends Controller
if ($do === 'ingredient') {
$model = Product::findOrFail($id);
$ProductIngredient = ProductIngredient::where('ingredient_id', $did)->where('product_id', $model->id)->first();
if ($ProductIngredient) {
$ProductIngredient->delete();
$productIngredient = ProductIngredient::where('ingredient_id', $did)->where('product_id', $model->id)->first();
if ($productIngredient) {
$productIngredient->delete();
\Session()->flash('alert-success', 'Eintrag gelöscht');
return redirect(route('admin_product_edit', [$model->id]));
}
return redirect(route('admin_product_edit', [$model->id]));
}
abort(404);
}
// Upload FILE -----------------------------------------------------------------------------------------------------------------------