From 8c90d95c69205bdd4e9d5a6221c161b68deee466 Mon Sep 17 00:00:00 2001 From: Kevin Adametz Date: Mon, 6 Jul 2026 10:05:35 +0000 Subject: [PATCH] Warenwirtschaft: OPT-2 Settings-CRUD-Basisklasse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Abstrakte SettingCrudController-Basis für die kleinen Stammdaten-CRUDs - TaxRate/DeliveryTime/DisposalReason/MaterialQuality/Location/SupplierCategory/PackagingMaterial auf ~25-Zeilen-Konfiguration reduziert - Identische Update*Request-Klassen entfernt (Update nutzt Store-Request, via updateRequestClass() überschreibbar) - Bilanz -441/+73 Zeilen; Grundlage für die Lagerort-CRUDs in AP-21 Co-Authored-By: Claude Fable 5 --- .../Inventory/DeliveryTimeController.php | 43 ++---- .../Inventory/DisposalReasonController.php | 43 ++---- .../Admin/Inventory/LocationController.php | 46 ++---- .../Inventory/MaterialQualityController.php | 47 ++---- .../Inventory/PackagingMaterialController.php | 47 ++---- .../Admin/Inventory/SettingCrudController.php | 139 ++++++++++++++++++ .../Inventory/SupplierCategoryController.php | 47 ++---- .../Admin/Inventory/TaxRateController.php | 43 ++---- .../Inventory/UpdateDeliveryTimeRequest.php | 35 ----- .../Inventory/UpdateDisposalReasonRequest.php | 5 - .../Inventory/UpdateLocationRequest.php | 31 ---- .../UpdateMaterialQualityRequest.php | 31 ---- .../UpdatePackagingMaterialRequest.php | 31 ---- .../UpdateSupplierCategoryRequest.php | 31 ---- .../Inventory/UpdateTaxRateRequest.php | 34 ----- ...ntwicklungsplan-aktualisiert-06-07-2026.md | 8 +- 16 files changed, 216 insertions(+), 445 deletions(-) create mode 100644 app/Http/Controllers/Admin/Inventory/SettingCrudController.php delete mode 100644 app/Http/Requests/Inventory/UpdateDeliveryTimeRequest.php delete mode 100644 app/Http/Requests/Inventory/UpdateDisposalReasonRequest.php delete mode 100644 app/Http/Requests/Inventory/UpdateLocationRequest.php delete mode 100644 app/Http/Requests/Inventory/UpdateMaterialQualityRequest.php delete mode 100644 app/Http/Requests/Inventory/UpdatePackagingMaterialRequest.php delete mode 100644 app/Http/Requests/Inventory/UpdateSupplierCategoryRequest.php delete mode 100644 app/Http/Requests/Inventory/UpdateTaxRateRequest.php diff --git a/app/Http/Controllers/Admin/Inventory/DeliveryTimeController.php b/app/Http/Controllers/Admin/Inventory/DeliveryTimeController.php index 0d18b37..5f5419e 100644 --- a/app/Http/Controllers/Admin/Inventory/DeliveryTimeController.php +++ b/app/Http/Controllers/Admin/Inventory/DeliveryTimeController.php @@ -2,53 +2,28 @@ namespace App\Http\Controllers\Admin\Inventory; -use App\Http\Controllers\Controller; use App\Http\Requests\Inventory\StoreDeliveryTimeRequest; -use App\Http\Requests\Inventory\UpdateDeliveryTimeRequest; use App\Models\DeliveryTime; -use Illuminate\Contracts\View\View; -use Illuminate\Http\RedirectResponse; -class DeliveryTimeController extends Controller +class DeliveryTimeController extends SettingCrudController { - public function create(): View + protected function modelClass(): string { - return view('admin.inventory.delivery-times.form', [ - 'model' => new DeliveryTime(['active' => true, 'pos' => 0]), - ]); + return DeliveryTime::class; } - public function store(StoreDeliveryTimeRequest $request): RedirectResponse + protected function viewPrefix(): string { - DeliveryTime::create($request->validated()); - - \Session::flash('alert-save', '1'); - - return redirect()->route('admin.inventory.general'); + return 'admin.inventory.delivery-times'; } - public function edit(DeliveryTime $deliveryTime): View + protected function redirectRoute(): string { - return view('admin.inventory.delivery-times.form', [ - 'model' => $deliveryTime, - ]); + return 'admin.inventory.general'; } - public function update(UpdateDeliveryTimeRequest $request, DeliveryTime $deliveryTime): RedirectResponse + protected function storeRequestClass(): string { - $deliveryTime->update($request->validated()); - - \Session::flash('alert-save', '1'); - - return redirect()->route('admin.inventory.general'); - } - - public function destroy(DeliveryTime $deliveryTime): RedirectResponse - { - $deliveryTime->delete(); - - \Session::flash('alert-success', __('Eintrag gelöscht')); - - return redirect()->route('admin.inventory.general'); + return StoreDeliveryTimeRequest::class; } } diff --git a/app/Http/Controllers/Admin/Inventory/DisposalReasonController.php b/app/Http/Controllers/Admin/Inventory/DisposalReasonController.php index 43ff27b..dd918b5 100644 --- a/app/Http/Controllers/Admin/Inventory/DisposalReasonController.php +++ b/app/Http/Controllers/Admin/Inventory/DisposalReasonController.php @@ -2,53 +2,28 @@ namespace App\Http\Controllers\Admin\Inventory; -use App\Http\Controllers\Controller; use App\Http\Requests\Inventory\StoreDisposalReasonRequest; -use App\Http\Requests\Inventory\UpdateDisposalReasonRequest; use App\Models\DisposalReason; -use Illuminate\Contracts\View\View; -use Illuminate\Http\RedirectResponse; -class DisposalReasonController extends Controller +class DisposalReasonController extends SettingCrudController { - public function create(): View + protected function modelClass(): string { - return view('admin.inventory.disposal-reasons.form', [ - 'model' => new DisposalReason(['active' => true, 'pos' => 0]), - ]); + return DisposalReason::class; } - public function store(StoreDisposalReasonRequest $request): RedirectResponse + protected function viewPrefix(): string { - DisposalReason::create($request->validated()); - - \Session::flash('alert-save', '1'); - - return redirect()->route('admin.inventory.general'); + return 'admin.inventory.disposal-reasons'; } - public function edit(DisposalReason $disposalReason): View + protected function redirectRoute(): string { - return view('admin.inventory.disposal-reasons.form', [ - 'model' => $disposalReason, - ]); + return 'admin.inventory.general'; } - public function update(UpdateDisposalReasonRequest $request, DisposalReason $disposalReason): RedirectResponse + protected function storeRequestClass(): string { - $disposalReason->update($request->validated()); - - \Session::flash('alert-save', '1'); - - return redirect()->route('admin.inventory.general'); - } - - public function destroy(DisposalReason $disposalReason): RedirectResponse - { - $disposalReason->delete(); - - \Session::flash('alert-success', __('Eintrag gelöscht')); - - return redirect()->route('admin.inventory.general'); + return StoreDisposalReasonRequest::class; } } diff --git a/app/Http/Controllers/Admin/Inventory/LocationController.php b/app/Http/Controllers/Admin/Inventory/LocationController.php index 48dc547..380d4fe 100644 --- a/app/Http/Controllers/Admin/Inventory/LocationController.php +++ b/app/Http/Controllers/Admin/Inventory/LocationController.php @@ -2,58 +2,38 @@ namespace App\Http\Controllers\Admin\Inventory; -use App\Http\Controllers\Controller; use App\Http\Requests\Inventory\StoreLocationRequest; -use App\Http\Requests\Inventory\UpdateLocationRequest; use App\Models\Location; -class LocationController extends Controller +class LocationController extends SettingCrudController { - public function index() + protected function modelClass(): string { - return view('admin.inventory.locations.index', [ - 'values' => Location::query()->orderBy('name')->get(), - ]); + return Location::class; } - public function create() + protected function viewPrefix(): string { - return view('admin.inventory.locations.form', [ - 'model' => new Location(['active' => true]), - ]); + return 'admin.inventory.locations'; } - public function store(StoreLocationRequest $request) + protected function redirectRoute(): string { - Location::create($request->validated()); - - \Session::flash('alert-save', '1'); - - return redirect()->route('admin.inventory.locations.index'); + return 'admin.inventory.locations.index'; } - public function edit(Location $location) + protected function storeRequestClass(): string { - return view('admin.inventory.locations.form', [ - 'model' => $location, - ]); + return StoreLocationRequest::class; } - public function update(UpdateLocationRequest $request, Location $location) + protected function newModelAttributes(): array { - $location->update($request->validated()); - - \Session::flash('alert-save', '1'); - - return redirect()->route('admin.inventory.locations.index'); + return ['active' => true]; } - public function destroy(Location $location) + protected function indexOrder(): array { - $location->delete(); - - \Session::flash('alert-success', __('Eintrag gelöscht')); - - return redirect()->route('admin.inventory.locations.index'); + return ['name']; } } diff --git a/app/Http/Controllers/Admin/Inventory/MaterialQualityController.php b/app/Http/Controllers/Admin/Inventory/MaterialQualityController.php index 61a6a8d..7fc5bd8 100644 --- a/app/Http/Controllers/Admin/Inventory/MaterialQualityController.php +++ b/app/Http/Controllers/Admin/Inventory/MaterialQualityController.php @@ -2,58 +2,33 @@ namespace App\Http\Controllers\Admin\Inventory; -use App\Http\Controllers\Controller; use App\Http\Requests\Inventory\StoreMaterialQualityRequest; -use App\Http\Requests\Inventory\UpdateMaterialQualityRequest; use App\Models\MaterialQuality; -class MaterialQualityController extends Controller +class MaterialQualityController extends SettingCrudController { - public function index() + protected function modelClass(): string { - return view('admin.inventory.material-qualities.index', [ - 'values' => MaterialQuality::query()->orderBy('pos')->orderBy('name')->get(), - ]); + return MaterialQuality::class; } - public function create() + protected function viewPrefix(): string { - return view('admin.inventory.material-qualities.form', [ - 'model' => new MaterialQuality(['pos' => 0]), - ]); + return 'admin.inventory.material-qualities'; } - public function store(StoreMaterialQualityRequest $request) + protected function redirectRoute(): string { - MaterialQuality::create($request->validated()); - - \Session::flash('alert-save', '1'); - - return redirect()->route('admin.inventory.material-qualities.index'); + return 'admin.inventory.material-qualities.index'; } - public function edit(MaterialQuality $materialQuality) + protected function storeRequestClass(): string { - return view('admin.inventory.material-qualities.form', [ - 'model' => $materialQuality, - ]); + return StoreMaterialQualityRequest::class; } - public function update(UpdateMaterialQualityRequest $request, MaterialQuality $materialQuality) + protected function newModelAttributes(): array { - $materialQuality->update($request->validated()); - - \Session::flash('alert-save', '1'); - - return redirect()->route('admin.inventory.material-qualities.index'); - } - - public function destroy(MaterialQuality $materialQuality) - { - $materialQuality->delete(); - - \Session::flash('alert-success', __('Eintrag gelöscht')); - - return redirect()->route('admin.inventory.material-qualities.index'); + return ['pos' => 0]; } } diff --git a/app/Http/Controllers/Admin/Inventory/PackagingMaterialController.php b/app/Http/Controllers/Admin/Inventory/PackagingMaterialController.php index 1dd5251..04014db 100644 --- a/app/Http/Controllers/Admin/Inventory/PackagingMaterialController.php +++ b/app/Http/Controllers/Admin/Inventory/PackagingMaterialController.php @@ -2,58 +2,33 @@ namespace App\Http\Controllers\Admin\Inventory; -use App\Http\Controllers\Controller; use App\Http\Requests\Inventory\StorePackagingMaterialRequest; -use App\Http\Requests\Inventory\UpdatePackagingMaterialRequest; use App\Models\PackagingMaterial; -class PackagingMaterialController extends Controller +class PackagingMaterialController extends SettingCrudController { - public function index() + protected function modelClass(): string { - return view('admin.inventory.packaging-materials.index', [ - 'values' => PackagingMaterial::query()->orderBy('pos')->orderBy('name')->get(), - ]); + return PackagingMaterial::class; } - public function create() + protected function viewPrefix(): string { - return view('admin.inventory.packaging-materials.form', [ - 'model' => new PackagingMaterial(['pos' => 0]), - ]); + return 'admin.inventory.packaging-materials'; } - public function store(StorePackagingMaterialRequest $request) + protected function redirectRoute(): string { - PackagingMaterial::create($request->validated()); - - \Session::flash('alert-save', '1'); - - return redirect()->route('admin.inventory.packaging-materials.index'); + return 'admin.inventory.packaging-materials.index'; } - public function edit(PackagingMaterial $packagingMaterial) + protected function storeRequestClass(): string { - return view('admin.inventory.packaging-materials.form', [ - 'model' => $packagingMaterial, - ]); + return StorePackagingMaterialRequest::class; } - public function update(UpdatePackagingMaterialRequest $request, PackagingMaterial $packagingMaterial) + protected function newModelAttributes(): array { - $packagingMaterial->update($request->validated()); - - \Session::flash('alert-save', '1'); - - return redirect()->route('admin.inventory.packaging-materials.index'); - } - - public function destroy(PackagingMaterial $packagingMaterial) - { - $packagingMaterial->delete(); - - \Session::flash('alert-success', __('Eintrag gelöscht')); - - return redirect()->route('admin.inventory.packaging-materials.index'); + return ['pos' => 0]; } } diff --git a/app/Http/Controllers/Admin/Inventory/SettingCrudController.php b/app/Http/Controllers/Admin/Inventory/SettingCrudController.php new file mode 100644 index 0000000..f4c0cba --- /dev/null +++ b/app/Http/Controllers/Admin/Inventory/SettingCrudController.php @@ -0,0 +1,139 @@ + */ + abstract protected function modelClass(): string; + + /** View-Prefix, z. B. 'admin.inventory.tax-rates' (erwartet .index/.form darunter). */ + abstract protected function viewPrefix(): string; + + /** Ziel-Route nach store/update/destroy. */ + abstract protected function redirectRoute(): string; + + /** @return class-string */ + abstract protected function storeRequestClass(): string; + + /** @return class-string Default: identisch zum Store-Request. */ + protected function updateRequestClass(): string + { + return $this->storeRequestClass(); + } + + /** + * Vorbelegung des leeren Models im Neu-Formular. + * + * @return array + */ + protected function newModelAttributes(): array + { + return ['active' => true, 'pos' => 0]; + } + + /** + * Sortierung der Index-Liste (nur für Resources mit index-Route relevant). + * + * @return array + */ + protected function indexOrder(): array + { + return ['pos', 'name']; + } + + public function index(): View + { + $query = $this->modelClass()::query(); + foreach ($this->indexOrder() as $column) { + $query->orderBy($column); + } + + return view($this->viewPrefix().'.index', [ + 'values' => $query->get(), + ]); + } + + public function create(): View + { + $class = $this->modelClass(); + + return view($this->viewPrefix().'.form', [ + 'model' => new $class($this->newModelAttributes()), + ]); + } + + public function store(): RedirectResponse + { + $this->modelClass()::create($this->validated($this->storeRequestClass())); + + \Session::flash('alert-save', '1'); + + return redirect()->route($this->redirectRoute()); + } + + public function edit(): View + { + return view($this->viewPrefix().'.form', [ + 'model' => $this->routeModel(), + ]); + } + + public function update(): RedirectResponse + { + $this->routeModel()->update($this->validated($this->updateRequestClass())); + + \Session::flash('alert-save', '1'); + + return redirect()->route($this->redirectRoute()); + } + + public function destroy(): RedirectResponse + { + $this->routeModel()->delete(); + + \Session::flash('alert-success', __('Eintrag gelöscht')); + + return redirect()->route($this->redirectRoute()); + } + + /** + * Validiert den aktuellen Request über den angegebenen FormRequest + * (Container-Auflösung triggert die Validierung wie bei Method-Injection). + * + * @param class-string $requestClass + * @return array + */ + protected function validated(string $requestClass): array + { + /** @var FormRequest $request */ + $request = app($requestClass); + + return $request->validated(); + } + + /** + * Löst das Model aus dem Resource-Routen-Parameter auf (ohne Typehint + * greift kein implizites Binding, der Parameter ist die rohe ID). + */ + protected function routeModel(): Model + { + $value = array_values(request()->route()->parameters())[0] ?? null; + + if ($value instanceof Model) { + return $value; + } + + return $this->modelClass()::query()->findOrFail($value); + } +} diff --git a/app/Http/Controllers/Admin/Inventory/SupplierCategoryController.php b/app/Http/Controllers/Admin/Inventory/SupplierCategoryController.php index 8dccda6..9aa5660 100644 --- a/app/Http/Controllers/Admin/Inventory/SupplierCategoryController.php +++ b/app/Http/Controllers/Admin/Inventory/SupplierCategoryController.php @@ -2,58 +2,33 @@ namespace App\Http\Controllers\Admin\Inventory; -use App\Http\Controllers\Controller; use App\Http\Requests\Inventory\StoreSupplierCategoryRequest; -use App\Http\Requests\Inventory\UpdateSupplierCategoryRequest; use App\Models\SupplierCategory; -class SupplierCategoryController extends Controller +class SupplierCategoryController extends SettingCrudController { - public function index() + protected function modelClass(): string { - return view('admin.inventory.supplier-categories.index', [ - 'values' => SupplierCategory::query()->orderBy('pos')->orderBy('name')->get(), - ]); + return SupplierCategory::class; } - public function create() + protected function viewPrefix(): string { - return view('admin.inventory.supplier-categories.form', [ - 'model' => new SupplierCategory(['pos' => 0]), - ]); + return 'admin.inventory.supplier-categories'; } - public function store(StoreSupplierCategoryRequest $request) + protected function redirectRoute(): string { - SupplierCategory::create($request->validated()); - - \Session::flash('alert-save', '1'); - - return redirect()->route('admin.inventory.supplier-categories.index'); + return 'admin.inventory.supplier-categories.index'; } - public function edit(SupplierCategory $supplierCategory) + protected function storeRequestClass(): string { - return view('admin.inventory.supplier-categories.form', [ - 'model' => $supplierCategory, - ]); + return StoreSupplierCategoryRequest::class; } - public function update(UpdateSupplierCategoryRequest $request, SupplierCategory $supplierCategory) + protected function newModelAttributes(): array { - $supplierCategory->update($request->validated()); - - \Session::flash('alert-save', '1'); - - return redirect()->route('admin.inventory.supplier-categories.index'); - } - - public function destroy(SupplierCategory $supplierCategory) - { - $supplierCategory->delete(); - - \Session::flash('alert-success', __('Eintrag gelöscht')); - - return redirect()->route('admin.inventory.supplier-categories.index'); + return ['pos' => 0]; } } diff --git a/app/Http/Controllers/Admin/Inventory/TaxRateController.php b/app/Http/Controllers/Admin/Inventory/TaxRateController.php index 1be9b4a..d80c064 100644 --- a/app/Http/Controllers/Admin/Inventory/TaxRateController.php +++ b/app/Http/Controllers/Admin/Inventory/TaxRateController.php @@ -2,53 +2,28 @@ namespace App\Http\Controllers\Admin\Inventory; -use App\Http\Controllers\Controller; use App\Http\Requests\Inventory\StoreTaxRateRequest; -use App\Http\Requests\Inventory\UpdateTaxRateRequest; use App\Models\TaxRate; -use Illuminate\Contracts\View\View; -use Illuminate\Http\RedirectResponse; -class TaxRateController extends Controller +class TaxRateController extends SettingCrudController { - public function create(): View + protected function modelClass(): string { - return view('admin.inventory.tax-rates.form', [ - 'model' => new TaxRate(['active' => true, 'pos' => 0]), - ]); + return TaxRate::class; } - public function store(StoreTaxRateRequest $request): RedirectResponse + protected function viewPrefix(): string { - TaxRate::create($request->validated()); - - \Session::flash('alert-save', '1'); - - return redirect()->route('admin.inventory.general'); + return 'admin.inventory.tax-rates'; } - public function edit(TaxRate $taxRate): View + protected function redirectRoute(): string { - return view('admin.inventory.tax-rates.form', [ - 'model' => $taxRate, - ]); + return 'admin.inventory.general'; } - public function update(UpdateTaxRateRequest $request, TaxRate $taxRate): RedirectResponse + protected function storeRequestClass(): string { - $taxRate->update($request->validated()); - - \Session::flash('alert-save', '1'); - - return redirect()->route('admin.inventory.general'); - } - - public function destroy(TaxRate $taxRate): RedirectResponse - { - $taxRate->delete(); - - \Session::flash('alert-success', __('Eintrag gelöscht')); - - return redirect()->route('admin.inventory.general'); + return StoreTaxRateRequest::class; } } diff --git a/app/Http/Requests/Inventory/UpdateDeliveryTimeRequest.php b/app/Http/Requests/Inventory/UpdateDeliveryTimeRequest.php deleted file mode 100644 index 474f5b1..0000000 --- a/app/Http/Requests/Inventory/UpdateDeliveryTimeRequest.php +++ /dev/null @@ -1,35 +0,0 @@ -> - */ - public function rules(): array - { - return [ - 'label' => ['required', 'string', 'max:255'], - 'days' => ['nullable', 'integer', 'min:0', 'max:65535'], - 'active' => ['sometimes', 'boolean'], - 'pos' => ['nullable', 'integer', 'min:0', 'max:255'], - ]; - } - - protected function prepareForValidation(): void - { - $this->merge([ - 'active' => $this->boolean('active'), - 'days' => $this->input('days', '') === '' ? null : $this->input('days'), - 'pos' => $this->input('pos', '') === '' ? 0 : $this->input('pos'), - ]); - } -} diff --git a/app/Http/Requests/Inventory/UpdateDisposalReasonRequest.php b/app/Http/Requests/Inventory/UpdateDisposalReasonRequest.php deleted file mode 100644 index 9740373..0000000 --- a/app/Http/Requests/Inventory/UpdateDisposalReasonRequest.php +++ /dev/null @@ -1,5 +0,0 @@ -> - */ - public function rules(): array - { - return [ - 'name' => ['required', 'string', 'max:255'], - 'active' => ['sometimes', 'boolean'], - ]; - } - - protected function prepareForValidation(): void - { - $this->merge([ - 'active' => $this->boolean('active'), - ]); - } -} diff --git a/app/Http/Requests/Inventory/UpdateMaterialQualityRequest.php b/app/Http/Requests/Inventory/UpdateMaterialQualityRequest.php deleted file mode 100644 index 123e603..0000000 --- a/app/Http/Requests/Inventory/UpdateMaterialQualityRequest.php +++ /dev/null @@ -1,31 +0,0 @@ -> - */ - public function rules(): array - { - return [ - 'name' => ['required', 'string', 'max:255'], - 'pos' => ['nullable', 'integer', 'min:0', 'max:255'], - ]; - } - - protected function prepareForValidation(): void - { - if ($this->has('pos') && $this->input('pos') === '') { - $this->merge(['pos' => 0]); - } - } -} diff --git a/app/Http/Requests/Inventory/UpdatePackagingMaterialRequest.php b/app/Http/Requests/Inventory/UpdatePackagingMaterialRequest.php deleted file mode 100644 index 2ede99a..0000000 --- a/app/Http/Requests/Inventory/UpdatePackagingMaterialRequest.php +++ /dev/null @@ -1,31 +0,0 @@ -> - */ - public function rules(): array - { - return [ - 'name' => ['required', 'string', 'max:255'], - 'pos' => ['nullable', 'integer', 'min:0', 'max:255'], - ]; - } - - protected function prepareForValidation(): void - { - if ($this->has('pos') && $this->input('pos') === '') { - $this->merge(['pos' => 0]); - } - } -} diff --git a/app/Http/Requests/Inventory/UpdateSupplierCategoryRequest.php b/app/Http/Requests/Inventory/UpdateSupplierCategoryRequest.php deleted file mode 100644 index b25ae50..0000000 --- a/app/Http/Requests/Inventory/UpdateSupplierCategoryRequest.php +++ /dev/null @@ -1,31 +0,0 @@ -> - */ - public function rules(): array - { - return [ - 'name' => ['required', 'string', 'max:255'], - 'pos' => ['nullable', 'integer', 'min:0', 'max:255'], - ]; - } - - protected function prepareForValidation(): void - { - if ($this->has('pos') && $this->input('pos') === '') { - $this->merge(['pos' => 0]); - } - } -} diff --git a/app/Http/Requests/Inventory/UpdateTaxRateRequest.php b/app/Http/Requests/Inventory/UpdateTaxRateRequest.php deleted file mode 100644 index 5cad11b..0000000 --- a/app/Http/Requests/Inventory/UpdateTaxRateRequest.php +++ /dev/null @@ -1,34 +0,0 @@ -> - */ - public function rules(): array - { - return [ - 'name' => ['required', 'string', 'max:255'], - 'percent' => ['required', 'numeric', 'min:0', 'max:100'], - 'active' => ['sometimes', 'boolean'], - 'pos' => ['nullable', 'integer', 'min:0', 'max:255'], - ]; - } - - protected function prepareForValidation(): void - { - $this->merge([ - 'active' => $this->boolean('active'), - 'pos' => $this->input('pos', '') === '' ? 0 : $this->input('pos'), - ]); - } -} diff --git a/dev/product management /entwicklungsplan-aktualisiert-06-07-2026.md b/dev/product management /entwicklungsplan-aktualisiert-06-07-2026.md index 414402e..6218bbc 100644 --- a/dev/product management /entwicklungsplan-aktualisiert-06-07-2026.md +++ b/dev/product management /entwicklungsplan-aktualisiert-06-07-2026.md @@ -98,8 +98,8 @@ Alle Punkte dieser älteren Runde sind in V4.0 eingeflossen und umgesetzt (URL-F | # | AP | Titel | Abhängigkeit | Aufwand | |---|---|---|---|---| | 1 | ✅ OPT-1 | Quick Wins (N+1, Indizes, ExampleTest) — **erledigt 06.07.2026** | – | 0,5 Tage | -| 2 | ➡️ OPT-2 | **NÄCHSTER SCHRITT:** Settings-CRUD-Basisklasse | – | 1 Tag | -| 3 | AP-21 | INCI-Erweiterungen (Lieferant+URL-Repeater, „nur aktive", Alternativname, Lagerort + 3 Stammdaten-CRUDs) | OPT-2 | 2–3,5 Tage | +| 2 | ✅ OPT-2 | Settings-CRUD-Basisklasse — **erledigt 06.07.2026** | – | 1 Tag | +| 3 | ➡️ AP-21 | **NÄCHSTER SCHRITT:** INCI-Erweiterungen (Lieferant+URL-Repeater, „nur aktive", Alternativname, Lagerort + 3 Stammdaten-CRUDs) | OPT-2 | 2–3,5 Tage | | 4 | AP-20 | Rohstoffbestand-Filter + „Kein Rohstoffbestand"-Flag | AP-21 | 1–2 Tage | | 5 | AP-23 | Rezeptur-Phasen (Hersteller-Rezeptur) | – | 3–5 Tage | | 6 | AP-24 | Chargen-Nr.-Präfix | – | 1 Tag | @@ -148,7 +148,7 @@ Die fachlichen Detailspezifikationen zu **AP-20, AP-21, AP-23, AP-24, AP-27, AP- | Datum | AP | Kurzbeschreibung | Tests | |---|---|---|---| | 06.07.2026 | **OPT-1 (Quick Wins)** | **N+1-Fix Ausschussliste:** `StockDisposalController@index` lädt jetzt `user.account` eager (vorher `user` → bis zu 500 Lazy-Loads durch `getFullName()`). **Composite-Indizes:** Migration `2026_07_06_113731_add_aggregation_indexes_to_stock_entries_table` — `stock_entries(entry_type, status, ingredient_id)` + `(entry_type, status, packaging_item_id)` für die Aggregations-Queries im `InventoryService`; auf DB ausgeführt. **Befund-Korrektur:** Der Index `production_ingredients(production_id, ingredient_id)` ist **nicht** redundant — er bedient den FK auf `production_id` mit (kein separater FK-Index vorhanden, per `SHOW INDEX` verifiziert) → bleibt bestehen. **Ungenutzter Eager-Load** `producedByUser` aus `ProductionRepository::listForIndex()` entfernt (wird nur in `show` gebraucht, dort bereits via `producedByUser.account` geladen). **`ExampleTest`** auf `assertRedirect()` umgestellt (Domain-Redirect auf `/`) — Suite dauerhaft 100 % grün. | Neuer Query-Count-Test `ausschuss-liste laedt benutzerkonten ohne n+1` in `StockDisposalTest` (verifiziert: schlägt ohne Fix fehl). Volle Suite: **155 grün, 538 Assertions** | -| _offen_ | OPT-2 | Settings-CRUD-Basisklasse (7 Controller) | – | +| 06.07.2026 | **OPT-2 (Settings-CRUD-Basisklasse)** | Neue abstrakte Basisklasse `app/Http/Controllers/Admin/Inventory/SettingCrudController.php`: generisches index/create/store/edit/update/destroy; Kind-Controller definieren nur noch `modelClass()`, `viewPrefix()`, `redirectRoute()`, `storeRequestClass()` (+ optional `newModelAttributes()`, `indexOrder()`, `updateRequestClass()`). Validierung per Container-Auflösung des FormRequests (Verhalten wie Method-Injection), Model-Auflösung aus dem Routen-Parameter via `findOrFail` (404-Verhalten unverändert). Umgestellt: `TaxRate`, `DeliveryTime`, `DisposalReason`, `MaterialQuality`, `Location`, `SupplierCategory`, `PackagingMaterial` (je ~50 → ~25 Zeilen reine Konfiguration). Die 7 `Update*Request`-Klassen waren mit den Store-Requests identisch und wurden entfernt (Update nutzt den Store-Request; bei künftiger Abweichung `updateRequestClass()` überschreiben). Form-Views bleiben bewusst je Entität (unterschiedliche Felder). **Bilanz: −441/+73 Zeilen.** Neue Settings-CRUDs (z. B. Raum/Regal/Fach in AP-21) = 1 Model + 1 Store-Request + ~25-Zeilen-Controller. | Volle Suite **155 grün, 538 Assertions** (inkl. `TaxRateSettingsTest`, `DeliveryTimeSettingsTest`, `DisposalReasonSettingsTest`, `InventoryPhase2Test`, `InventoryPhase3Test`) | | _offen_ | AP-21 | INCI-Erweiterungen | – | | _offen_ | AP-20 | Rohstoffbestand-Filter + Flag | – | | _offen_ | AP-23 | Rezeptur-Phasen | – | @@ -159,4 +159,4 @@ Die fachlichen Detailspezifikationen zu **AP-20, AP-21, AP-23, AP-24, AP-27, AP- | _offen_ | AP-13 | Shop-Bestandsabzug | – | | _offen_ | AP-14/15/16/17 | Audit-Trail, Blockrechte, 2FA, WaWi-Einstellungen | – | -> **➡️ HIER GEHT ES WEITER: OPT-2 (Settings-CRUD-Basisklasse).** Danach AP-21 gemäß V5.0-Spezifikation — alle Klärungspunkte sind beantwortet (§4): Lagerort = drei getrennte Stammdaten-Tabellen Raum/Regal/Fach. +> **➡️ HIER GEHT ES WEITER: AP-21 (INCI-Erweiterungen)** gemäß V5.0-Spezifikation — alle Klärungspunkte sind beantwortet (§4): Lagerort = drei getrennte Stammdaten-Tabellen Raum/Regal/Fach, als `SettingCrudController`-Kinder (OPT-2) anlegen.