April 2026 waren Wirtschaft Feedback
This commit is contained in:
parent
02f2a4c23e
commit
9ce711d6b2
167 changed files with 25278 additions and 8518 deletions
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Inventory;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Inventory\StorePackagingItemRequest;
|
||||
use App\Http\Requests\Inventory\UpdatePackagingItemRequest;
|
||||
use App\Models\PackagingItem;
|
||||
use App\Models\PackagingMaterial;
|
||||
use App\Models\Supplier;
|
||||
use App\Repositories\PackagingItemRepository;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PackagingItemController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
protected PackagingItemRepository $packagingItemRepository
|
||||
) {}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$category = $request->get('category', 'packaging');
|
||||
$isShipping = $category === 'shipping';
|
||||
|
||||
$query = PackagingItem::query()
|
||||
->with(['packagingMaterial', 'supplier'])
|
||||
->orderBy('name');
|
||||
|
||||
if ($isShipping) {
|
||||
$query->whereIn('category', ['shipping', 'label', 'shipping_office']);
|
||||
} else {
|
||||
$query->where('category', 'packaging');
|
||||
}
|
||||
|
||||
return view('admin.inventory.packaging-items.index', [
|
||||
'values' => $query->get(),
|
||||
'category' => $category,
|
||||
'pageTitle' => $isShipping ? __('Versandverpackung') : __('Produktverpackung'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
$category = $request->get('category', 'packaging');
|
||||
|
||||
return view('admin.inventory.packaging-items.form', [
|
||||
'model' => new PackagingItem(['active' => true, 'category' => $category === 'shipping' ? 'shipping' : 'packaging', 'weight_grams' => 0]),
|
||||
'packagingMaterials' => PackagingMaterial::query()->orderBy('pos')->orderBy('name')->get(),
|
||||
'suppliers' => Supplier::query()->orderBy('name')->get(),
|
||||
'category' => $category,
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(StorePackagingItemRequest $request)
|
||||
{
|
||||
$item = $this->packagingItemRepository->create($request->validated());
|
||||
|
||||
\Session::flash('alert-save', '1');
|
||||
|
||||
$category = in_array($item->category, ['shipping', 'label', 'shipping_office']) ? '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';
|
||||
|
||||
return view('admin.inventory.packaging-items.form', [
|
||||
'model' => $packagingItem,
|
||||
'packagingMaterials' => PackagingMaterial::query()->orderBy('pos')->orderBy('name')->get(),
|
||||
'suppliers' => Supplier::query()->orderBy('name')->get(),
|
||||
'category' => $category,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(UpdatePackagingItemRequest $request, PackagingItem $packagingItem)
|
||||
{
|
||||
$this->packagingItemRepository->update($packagingItem, $request->validated());
|
||||
|
||||
\Session::flash('alert-save', '1');
|
||||
|
||||
$category = in_array($packagingItem->category, ['shipping', 'label', 'shipping_office']) ? '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';
|
||||
|
||||
$packagingItem->delete();
|
||||
|
||||
\Session::flash('alert-success', __('Eintrag gelöscht'));
|
||||
|
||||
return redirect()->route('admin.inventory.packaging-items.index', ['category' => $category]);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue