April 2026 waren Wirtschaft Feedback
This commit is contained in:
parent
02f2a4c23e
commit
9ce711d6b2
167 changed files with 25278 additions and 8518 deletions
54
app/Http/Requests/Inventory/StoreProductionRequest.php
Normal file
54
app/Http/Requests/Inventory/StoreProductionRequest.php
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreProductionRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, mixed|string>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'product_id' => ['required', 'integer', 'exists:products,id'],
|
||||
'location_id' => ['required', 'integer', 'exists:locations,id'],
|
||||
'produced_at' => ['required', 'date'],
|
||||
'quantity' => ['required', 'integer', 'min:1'],
|
||||
'notes' => ['nullable', 'string', 'max:2000'],
|
||||
'ingredient_lines' => ['required', 'array', 'min:1'],
|
||||
'ingredient_lines.*.ingredient_id' => ['required', 'integer', 'exists:ingredients,id'],
|
||||
'ingredient_lines.*.stock_entry_id' => ['required', 'integer', 'exists:stock_entries,id'],
|
||||
'ingredient_lines.*.quantity_used' => ['required', 'string'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function validatedPayload(): array
|
||||
{
|
||||
$data = $this->validated();
|
||||
|
||||
return [
|
||||
'product_id' => (int) $data['product_id'],
|
||||
'location_id' => (int) $data['location_id'],
|
||||
'produced_at' => $data['produced_at'],
|
||||
'quantity' => (int) $data['quantity'],
|
||||
'notes' => $data['notes'] ?? null,
|
||||
'ingredient_lines' => array_map(function (array $line): array {
|
||||
return [
|
||||
'ingredient_id' => (int) $line['ingredient_id'],
|
||||
'stock_entry_id' => (int) $line['stock_entry_id'],
|
||||
'quantity_used' => $line['quantity_used'],
|
||||
];
|
||||
}, $data['ingredient_lines']),
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue