Warenwirtschaft: OPT-2 Settings-CRUD-Basisklasse
- 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 <noreply@anthropic.com>
This commit is contained in:
parent
65f949dd7a
commit
8c90d95c69
16 changed files with 216 additions and 445 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
139
app/Http/Controllers/Admin/Inventory/SettingCrudController.php
Normal file
139
app/Http/Controllers/Admin/Inventory/SettingCrudController.php
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Inventory;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
/**
|
||||
* Gemeinsame Basis der kleinen Stammdaten-CRUDs (Warenwirtschaft → Einstellungen).
|
||||
* Kind-Controller definieren nur Model, View-Prefix, FormRequest und Redirect-Ziel.
|
||||
*/
|
||||
abstract class SettingCrudController extends Controller
|
||||
{
|
||||
/** @return class-string<Model> */
|
||||
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<FormRequest> */
|
||||
abstract protected function storeRequestClass(): string;
|
||||
|
||||
/** @return class-string<FormRequest> Default: identisch zum Store-Request. */
|
||||
protected function updateRequestClass(): string
|
||||
{
|
||||
return $this->storeRequestClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Vorbelegung des leeren Models im Neu-Formular.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function newModelAttributes(): array
|
||||
{
|
||||
return ['active' => true, 'pos' => 0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sortierung der Index-Liste (nur für Resources mit index-Route relevant).
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
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<FormRequest> $requestClass
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateDeliveryTimeRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, string>>
|
||||
*/
|
||||
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'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
class UpdateDisposalReasonRequest extends StoreDisposalReasonRequest {}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateLocationRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, string>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'active' => ['sometimes', 'boolean'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'active' => $this->boolean('active'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateMaterialQualityRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, string>>
|
||||
*/
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdatePackagingMaterialRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, string>>
|
||||
*/
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateSupplierCategoryRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, string>>
|
||||
*/
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateTaxRateRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, string>>
|
||||
*/
|
||||
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'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue