Umsetzung der Warenwirtschafts-/Produktmanagement-Erweiterung gemaess Entwicklungsplan V4.0: - AP-00: Regressionsbasis fuer 5.1-Features (ProductPhase51Test) - AP-01: URL-Bugfixes B1/B2 (suppliers/packaging-items, breitere url-Spalten) - AP-04/04.1: iPad-taugliche, vereinheitlichte Tabellen-Aktionen - AP-05: Einstellungen "Allgemein" mit UST-Saetzen (tax_rates) und Lieferzeit-Vorlagen (delivery_times, inkl. Tage-Feld) - AP-06: Lieferanten um Bestellweg, Bestell-Mail/-URL und Lieferzeit erweitert - AP-07/07.1: INCI um Lieferanten-Mehrfachwahl, UST und Lieferzeit erweitert; Lieferanten-Detailansicht im Modal mit pflegbaren INCI-/Verpackungslisten - AP-08: Einkauf um UST-Snapshot, Netto/Brutto-Automatik und Duplizieren erweitert Entwicklungsplan aktualisiert: alle Klaerungspunkte (§5) vom Kunden beantwortet und in die jeweiligen APs eingearbeitet (AP-02/03/09/13/15), neues AP-18 (Hinweise-Doku unter Einstellungen) ergaenzt. Naechster Schritt eindeutig markiert: AP-09 (Produktion auf Hersteller-Rezeptur, kein Fallback, Warnung).
61 lines
2.1 KiB
PHP
61 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class StoreIngredientRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, array<int, mixed>>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'name' => ['required', 'string', 'max:255'],
|
|
'inci' => ['nullable', 'string'],
|
|
'effect' => ['nullable', 'string'],
|
|
'pos' => ['nullable', 'integer', 'min:0', 'max:255'],
|
|
'default_factor' => ['nullable', 'numeric', 'min:0'],
|
|
'min_stock_alert' => ['nullable', 'numeric', 'min:0'],
|
|
'material_quality_id' => ['nullable', 'integer', 'exists:material_qualities,id'],
|
|
'tax_rate_id' => ['nullable', 'integer', 'exists:tax_rates,id'],
|
|
'delivery_time' => ['nullable', 'string', 'max:255'],
|
|
'delivery_time_days' => ['nullable', 'integer', 'min:0', 'max:65535'],
|
|
'supplier_ids' => ['nullable', 'array'],
|
|
'supplier_ids.*' => ['integer', 'exists:suppliers,id'],
|
|
'active' => ['sometimes', 'boolean'],
|
|
];
|
|
}
|
|
|
|
protected function prepareForValidation(): void
|
|
{
|
|
$this->merge([
|
|
'active' => $this->boolean('active'),
|
|
'default_factor' => $this->normalizeDecimal($this->input('default_factor')),
|
|
'min_stock_alert' => $this->normalizeDecimal($this->input('min_stock_alert')),
|
|
'material_quality_id' => $this->nullIfEmpty($this->input('material_quality_id')),
|
|
'tax_rate_id' => $this->nullIfEmpty($this->input('tax_rate_id')),
|
|
'delivery_time_days' => $this->nullIfEmpty($this->input('delivery_time_days')),
|
|
]);
|
|
}
|
|
|
|
private function normalizeDecimal(mixed $value): ?string
|
|
{
|
|
if ($value === null || $value === '') {
|
|
return null;
|
|
}
|
|
|
|
return (string) reFormatNumber($value);
|
|
}
|
|
|
|
private function nullIfEmpty(mixed $value): mixed
|
|
{
|
|
return $value === '' ? null : $value;
|
|
}
|
|
}
|