- M-2: Produktionen buchen Bestand — StoreProductionRequest verlangt
jetzt admin >= 7 (wie manuelle Bestandsbewegungen); create/edit/copy
im Controller gegated, UI-Buttons für niedrigere Stufen ausgeblendet.
- M-3: Ausschuss-/Bewegungs-/Produktions-Buttons nur noch für
Berechtigte sichtbar (keine toten Formulare mehr).
- M-6: Zustandsändernde GET-Routen umgestellt — stock-entries/copy
jetzt POST mit CSRF; /admin/product/delete jetzt DELETE-Formulare
(Produktliste + Rezeptur-Zeile im Produktformular).
- M-7: ProductController::imageAttribute whitelistet Spalten
('active', 'pos') + numerische Werte, sonst 400 — kein beliebiger
Spalten-Write per URL mehr.
- M-10: URL-Felder (Lieferant, Verpackungsartikel, INCI-Lieferanten-
Repeater) validieren url:http,https — keine speicherbaren
javascript:-Links mehr.
Tests: ProductionHardeningTest +2; drei bestehende Tests an neue
Regeln angepasst (admin-Level 7 für Produktions-Formular, POST-Copy).
Suite: 231 grün.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
47 lines
1.5 KiB
PHP
47 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Inventory;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class UpdatePackagingItemRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, array<int, mixed>>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'packaging_material_id' => ['required', 'integer', 'exists:packaging_materials,id'],
|
|
'supplier_id' => ['nullable', 'integer', 'exists:suppliers,id'],
|
|
'name' => ['required', 'string', 'max:255'],
|
|
'category' => ['required', Rule::in(['packaging', 'shipping'])],
|
|
'weight_grams' => ['nullable', 'numeric', 'min:0'],
|
|
'min_stock_alert' => ['nullable', 'integer', 'min:0'],
|
|
'url' => ['nullable', 'string', 'url:http,https', 'max:2048'],
|
|
'product_id' => ['nullable', 'integer', 'exists:products,id'],
|
|
'active' => ['sometimes', 'boolean'],
|
|
];
|
|
}
|
|
|
|
protected function prepareForValidation(): void
|
|
{
|
|
$this->merge([
|
|
'active' => $this->boolean('active'),
|
|
'category' => trim((string) $this->input('category')),
|
|
'weight_grams' => $this->filled('weight_grams') ? reFormatNumber($this->input('weight_grams')) : null,
|
|
]);
|
|
|
|
foreach (['supplier_id', 'product_id', 'min_stock_alert'] as $key) {
|
|
if ($this->input($key) === '' || $this->input($key) === null) {
|
|
$this->merge([$key => null]);
|
|
}
|
|
}
|
|
}
|
|
}
|