diff --git a/app/Http/Controllers/Admin/Inventory/ProductionController.php b/app/Http/Controllers/Admin/Inventory/ProductionController.php index 4a44cea..19c5b14 100644 --- a/app/Http/Controllers/Admin/Inventory/ProductionController.php +++ b/app/Http/Controllers/Admin/Inventory/ProductionController.php @@ -33,8 +33,13 @@ class ProductionController extends Controller ]); } - public function create(Request $request): View + public function create(Request $request): View|RedirectResponse { + // Audit M-2: Produktionen buchen Bestand — nur admin >= 7. + if (! auth()->user()->isAdmin()) { + return redirect()->route('home'); + } + $defaultLocationId = Location::query()->where('name', 'like', '%öln%')->value('id') ?? Location::query()->where('active', true)->first()?->id; @@ -101,8 +106,11 @@ class ProductionController extends Controller ]); } - public function edit(Production $production): View + public function edit(Production $production): View|RedirectResponse { + if (! auth()->user()->isAdmin()) { + return redirect()->route('home'); + } $production->load([ 'product', 'location', @@ -161,8 +169,11 @@ class ProductionController extends Controller return redirect()->route('admin.inventory.productions.show', $production); } - public function copy(Production $production): View + public function copy(Production $production): View|RedirectResponse { + if (! auth()->user()->isAdmin()) { + return redirect()->route('home'); + } $production->load([ 'product', 'productionIngredients.ingredient', diff --git a/app/Http/Controllers/ProductController.php b/app/Http/Controllers/ProductController.php index 0a434f0..3667ab6 100755 --- a/app/Http/Controllers/ProductController.php +++ b/app/Http/Controllers/ProductController.php @@ -222,8 +222,13 @@ class ProductController extends Controller public function imageAttribute($product_id, $attr, $val = false) { + // Audit M-7: nur erlaubte Spalten — $attr kommt aus der URL und würde + // sonst die $fillable-Whitelist per dynamischer Property umgehen. + if (! in_array($attr, ['active', 'pos'], true) || ! is_numeric($val)) { + abort(400); + } - if (is_numeric($val) && $val < 0) { + if ($val < 0) { $val = 0; } diff --git a/app/Http/Requests/Inventory/StorePackagingItemRequest.php b/app/Http/Requests/Inventory/StorePackagingItemRequest.php index 26f9e32..6eac1d5 100644 --- a/app/Http/Requests/Inventory/StorePackagingItemRequest.php +++ b/app/Http/Requests/Inventory/StorePackagingItemRequest.php @@ -24,7 +24,7 @@ class StorePackagingItemRequest extends FormRequest 'category' => ['required', Rule::in(['packaging', 'shipping'])], 'weight_grams' => ['nullable', 'numeric', 'min:0'], 'min_stock_alert' => ['nullable', 'integer', 'min:0'], - 'url' => ['nullable', 'string', 'max:2048'], + 'url' => ['nullable', 'string', 'url:http,https', 'max:2048'], 'product_id' => ['nullable', 'integer', 'exists:products,id'], 'active' => ['sometimes', 'boolean'], ]; diff --git a/app/Http/Requests/Inventory/StoreProductionRequest.php b/app/Http/Requests/Inventory/StoreProductionRequest.php index b5a5ac3..d0a19ab 100644 --- a/app/Http/Requests/Inventory/StoreProductionRequest.php +++ b/app/Http/Requests/Inventory/StoreProductionRequest.php @@ -9,7 +9,9 @@ class StoreProductionRequest extends FormRequest { public function authorize(): bool { - return true; + // Audit M-2: Produktionen buchen Produktbestand — gleiche Schranke + // wie manuelle Bestandsbewegungen (admin >= 7). + return (bool) $this->user()?->isAdmin(); } /** diff --git a/app/Http/Requests/Inventory/StoreSupplierRequest.php b/app/Http/Requests/Inventory/StoreSupplierRequest.php index ef0b408..b399c11 100644 --- a/app/Http/Requests/Inventory/StoreSupplierRequest.php +++ b/app/Http/Requests/Inventory/StoreSupplierRequest.php @@ -18,10 +18,10 @@ class StoreSupplierRequest extends FormRequest { return [ 'name' => ['required', 'string', 'max:255'], - 'url' => ['nullable', 'string', 'max:2048'], + 'url' => ['nullable', 'string', 'url:http,https', 'max:2048'], 'order_method' => ['nullable', 'in:email,online_shop'], 'order_email' => ['nullable', 'email', 'max:255'], - 'order_url' => ['nullable', 'string', 'max:2048'], + 'order_url' => ['nullable', 'string', 'url:http,https', 'max:2048'], 'delivery_time' => ['nullable', 'string', 'max:255'], 'delivery_time_days' => ['nullable', 'integer', 'min:0', 'max:65535'], 'contact_person' => ['nullable', 'string', 'max:255'], diff --git a/app/Http/Requests/Inventory/UpdatePackagingItemRequest.php b/app/Http/Requests/Inventory/UpdatePackagingItemRequest.php index da67a49..4b4785f 100644 --- a/app/Http/Requests/Inventory/UpdatePackagingItemRequest.php +++ b/app/Http/Requests/Inventory/UpdatePackagingItemRequest.php @@ -24,7 +24,7 @@ class UpdatePackagingItemRequest extends FormRequest 'category' => ['required', Rule::in(['packaging', 'shipping'])], 'weight_grams' => ['nullable', 'numeric', 'min:0'], 'min_stock_alert' => ['nullable', 'integer', 'min:0'], - 'url' => ['nullable', 'string', 'max:2048'], + 'url' => ['nullable', 'string', 'url:http,https', 'max:2048'], 'product_id' => ['nullable', 'integer', 'exists:products,id'], 'active' => ['sometimes', 'boolean'], ]; diff --git a/app/Http/Requests/Inventory/UpdateSupplierRequest.php b/app/Http/Requests/Inventory/UpdateSupplierRequest.php index 271ad44..4d8de67 100644 --- a/app/Http/Requests/Inventory/UpdateSupplierRequest.php +++ b/app/Http/Requests/Inventory/UpdateSupplierRequest.php @@ -18,10 +18,10 @@ class UpdateSupplierRequest extends FormRequest { return [ 'name' => ['required', 'string', 'max:255'], - 'url' => ['nullable', 'string', 'max:2048'], + 'url' => ['nullable', 'string', 'url:http,https', 'max:2048'], 'order_method' => ['nullable', 'in:email,online_shop'], 'order_email' => ['nullable', 'email', 'max:255'], - 'order_url' => ['nullable', 'string', 'max:2048'], + 'order_url' => ['nullable', 'string', 'url:http,https', 'max:2048'], 'delivery_time' => ['nullable', 'string', 'max:255'], 'delivery_time_days' => ['nullable', 'integer', 'min:0', 'max:65535'], 'contact_person' => ['nullable', 'string', 'max:255'], diff --git a/app/Http/Requests/StoreIngredientRequest.php b/app/Http/Requests/StoreIngredientRequest.php index 9b859ab..6f532d2 100644 --- a/app/Http/Requests/StoreIngredientRequest.php +++ b/app/Http/Requests/StoreIngredientRequest.php @@ -30,7 +30,7 @@ class StoreIngredientRequest extends FormRequest 'delivery_time_days' => ['nullable', 'integer', 'min:0', 'max:65535'], 'suppliers' => ['nullable', 'array'], 'suppliers.*.id' => ['nullable', 'integer', 'exists:suppliers,id'], - 'suppliers.*.url' => ['nullable', 'string', 'max:2048'], + 'suppliers.*.url' => ['nullable', 'string', 'url:http,https', 'max:2048'], 'storage_room_id' => ['nullable', 'integer', 'exists:storage_rooms,id'], 'storage_shelf_id' => ['nullable', 'integer', 'exists:storage_shelves,id'], 'storage_slot_id' => ['nullable', 'integer', 'exists:storage_slots,id'], diff --git a/resources/views/admin/inventory/product-stock/index.blade.php b/resources/views/admin/inventory/product-stock/index.blade.php index 2597eff..3eb355c 100644 --- a/resources/views/admin/inventory/product-stock/index.blade.php +++ b/resources/views/admin/inventory/product-stock/index.blade.php @@ -132,10 +132,10 @@ + + {{ __('Produzieren') }} @endif - - {{ __('Produzieren') }} diff --git a/resources/views/admin/inventory/productions/index.blade.php b/resources/views/admin/inventory/productions/index.blade.php index fb42b20..dc6e131 100644 --- a/resources/views/admin/inventory/productions/index.blade.php +++ b/resources/views/admin/inventory/productions/index.blade.php @@ -10,9 +10,11 @@
{{ __('Erfasste Produktionschargen inkl. Rohstoff- und Verpackungsverbrauch') }}