April 2026 waren Wirtschaft Feedback
This commit is contained in:
parent
02f2a4c23e
commit
9ce711d6b2
167 changed files with 25278 additions and 8518 deletions
34
app/Http/Requests/Inventory/ReceiveStockEntryRequest.php
Normal file
34
app/Http/Requests/Inventory/ReceiveStockEntryRequest.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ReceiveStockEntryRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, mixed>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'received_at' => ['required', 'date'],
|
||||
'received_quantity' => ['required', 'numeric', 'min:0.000001'],
|
||||
'batch_number' => ['nullable', 'string', 'max:100'],
|
||||
'best_before' => ['nullable', 'date'],
|
||||
'quality_id' => ['nullable', 'integer', 'exists:material_qualities,id'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'received_quantity' => reFormatNumber($this->input('received_quantity')),
|
||||
]);
|
||||
}
|
||||
}
|
||||
31
app/Http/Requests/Inventory/StoreLocationRequest.php
Normal file
31
app/Http/Requests/Inventory/StoreLocationRequest.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreLocationRequest 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'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
31
app/Http/Requests/Inventory/StoreMaterialQualityRequest.php
Normal file
31
app/Http/Requests/Inventory/StoreMaterialQualityRequest.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreMaterialQualityRequest 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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
45
app/Http/Requests/Inventory/StorePackagingItemRequest.php
Normal file
45
app/Http/Requests/Inventory/StorePackagingItemRequest.php
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StorePackagingItemRequest 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', 'label', 'shipping_office'])],
|
||||
'weight_grams' => ['nullable', 'numeric', 'min:0'],
|
||||
'min_stock_alert' => ['nullable', 'integer', 'min:0'],
|
||||
'url' => ['nullable', 'url', 'max:500'],
|
||||
'product_id' => ['nullable', 'integer', 'exists:products,id'],
|
||||
'active' => ['sometimes', 'boolean'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'active' => $this->boolean('active'),
|
||||
]);
|
||||
|
||||
foreach (['supplier_id', 'product_id', 'min_stock_alert'] as $key) {
|
||||
if ($this->input($key) === '' || $this->input($key) === null) {
|
||||
$this->merge([$key => null]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StorePackagingMaterialRequest 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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
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']),
|
||||
];
|
||||
}
|
||||
}
|
||||
73
app/Http/Requests/Inventory/StoreStockEntryRequest.php
Normal file
73
app/Http/Requests/Inventory/StoreStockEntryRequest.php
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
class StoreStockEntryRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, mixed>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'entry_type' => ['required', Rule::in(['ingredient', 'packaging', 'label', 'shipping_office'])],
|
||||
'ingredient_id' => ['nullable', 'integer', 'exists:ingredients,id'],
|
||||
'packaging_item_id' => ['nullable', 'integer', 'exists:packaging_items,id'],
|
||||
'supplier_id' => ['required', 'integer', 'exists:suppliers,id'],
|
||||
'location_id' => ['required', 'integer', 'exists:locations,id'],
|
||||
'ordered_at' => ['required', 'date'],
|
||||
'ordered_quantity' => ['required', 'numeric', 'min:0.000001'],
|
||||
'price_per_kg' => ['nullable', 'numeric', 'min:0'],
|
||||
'price_total' => ['nullable', 'numeric', 'min:0'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'ordered_quantity' => reFormatNumber($this->input('ordered_quantity')),
|
||||
'price_per_kg' => $this->filled('price_per_kg') ? reFormatNumber($this->input('price_per_kg')) : null,
|
||||
'price_total' => $this->filled('price_total') ? reFormatNumber($this->input('price_total')) : null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function withValidator(Validator $validator): void
|
||||
{
|
||||
$validator->after(function (Validator $validator): void {
|
||||
$type = $this->input('entry_type');
|
||||
if ($type === 'ingredient') {
|
||||
if (empty($this->input('ingredient_id'))) {
|
||||
$validator->errors()->add('ingredient_id', __('Bitte einen Inhaltsstoff wählen.'));
|
||||
}
|
||||
} elseif (! empty($type)) {
|
||||
if (empty($this->input('packaging_item_id'))) {
|
||||
$validator->errors()->add('packaging_item_id', __('Bitte einen Verpackungsartikel wählen.'));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function validatedPayload(): array
|
||||
{
|
||||
$data = $this->validated();
|
||||
if (($data['entry_type'] ?? '') === 'ingredient') {
|
||||
$data['packaging_item_id'] = null;
|
||||
} else {
|
||||
$data['ingredient_id'] = null;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
31
app/Http/Requests/Inventory/StoreSupplierCategoryRequest.php
Normal file
31
app/Http/Requests/Inventory/StoreSupplierCategoryRequest.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreSupplierCategoryRequest 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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
39
app/Http/Requests/Inventory/StoreSupplierRequest.php
Normal file
39
app/Http/Requests/Inventory/StoreSupplierRequest.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreSupplierRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, mixed>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'url' => ['nullable', 'string', 'max:2048'],
|
||||
'contact_person' => ['nullable', 'string', 'max:255'],
|
||||
'email' => ['nullable', 'email', 'max:255'],
|
||||
'phone' => ['nullable', 'string', 'max:100'],
|
||||
'country_id' => ['required', 'integer', 'exists:countries,id'],
|
||||
'notes' => ['nullable', 'string'],
|
||||
'active' => ['sometimes', 'boolean'],
|
||||
'supplier_category_ids' => ['nullable', 'array'],
|
||||
'supplier_category_ids.*' => ['integer', 'exists:supplier_categories,id'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'active' => $this->boolean('active'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
31
app/Http/Requests/Inventory/UpdateLocationRequest.php
Normal file
31
app/Http/Requests/Inventory/UpdateLocationRequest.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?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'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
31
app/Http/Requests/Inventory/UpdateMaterialQualityRequest.php
Normal file
31
app/Http/Requests/Inventory/UpdateMaterialQualityRequest.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
45
app/Http/Requests/Inventory/UpdatePackagingItemRequest.php
Normal file
45
app/Http/Requests/Inventory/UpdatePackagingItemRequest.php
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?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', 'label', 'shipping_office'])],
|
||||
'weight_grams' => ['nullable', 'numeric', 'min:0'],
|
||||
'min_stock_alert' => ['nullable', 'integer', 'min:0'],
|
||||
'url' => ['nullable', 'url', 'max:500'],
|
||||
'product_id' => ['nullable', 'integer', 'exists:products,id'],
|
||||
'active' => ['sometimes', 'boolean'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'active' => $this->boolean('active'),
|
||||
]);
|
||||
|
||||
foreach (['supplier_id', 'product_id', 'min_stock_alert'] as $key) {
|
||||
if ($this->input($key) === '' || $this->input($key) === null) {
|
||||
$this->merge([$key => null]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
73
app/Http/Requests/Inventory/UpdateStockEntryRequest.php
Normal file
73
app/Http/Requests/Inventory/UpdateStockEntryRequest.php
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
class UpdateStockEntryRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, mixed>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'entry_type' => ['required', Rule::in(['ingredient', 'packaging', 'label', 'shipping_office'])],
|
||||
'ingredient_id' => ['nullable', 'integer', 'exists:ingredients,id'],
|
||||
'packaging_item_id' => ['nullable', 'integer', 'exists:packaging_items,id'],
|
||||
'supplier_id' => ['required', 'integer', 'exists:suppliers,id'],
|
||||
'location_id' => ['required', 'integer', 'exists:locations,id'],
|
||||
'ordered_at' => ['required', 'date'],
|
||||
'ordered_quantity' => ['required', 'numeric', 'min:0.000001'],
|
||||
'price_per_kg' => ['nullable', 'numeric', 'min:0'],
|
||||
'price_total' => ['nullable', 'numeric', 'min:0'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'ordered_quantity' => reFormatNumber($this->input('ordered_quantity')),
|
||||
'price_per_kg' => $this->filled('price_per_kg') ? reFormatNumber($this->input('price_per_kg')) : null,
|
||||
'price_total' => $this->filled('price_total') ? reFormatNumber($this->input('price_total')) : null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function withValidator(Validator $validator): void
|
||||
{
|
||||
$validator->after(function (Validator $validator): void {
|
||||
$type = $this->input('entry_type');
|
||||
if ($type === 'ingredient') {
|
||||
if (empty($this->input('ingredient_id'))) {
|
||||
$validator->errors()->add('ingredient_id', __('Bitte einen Inhaltsstoff wählen.'));
|
||||
}
|
||||
} elseif (! empty($type)) {
|
||||
if (empty($this->input('packaging_item_id'))) {
|
||||
$validator->errors()->add('packaging_item_id', __('Bitte einen Verpackungsartikel wählen.'));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function validatedPayload(): array
|
||||
{
|
||||
$data = $this->validated();
|
||||
if (($data['entry_type'] ?? '') === 'ingredient') {
|
||||
$data['packaging_item_id'] = null;
|
||||
} else {
|
||||
$data['ingredient_id'] = null;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
39
app/Http/Requests/Inventory/UpdateSupplierRequest.php
Normal file
39
app/Http/Requests/Inventory/UpdateSupplierRequest.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateSupplierRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, mixed>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'url' => ['nullable', 'string', 'max:2048'],
|
||||
'contact_person' => ['nullable', 'string', 'max:255'],
|
||||
'email' => ['nullable', 'email', 'max:255'],
|
||||
'phone' => ['nullable', 'string', 'max:100'],
|
||||
'country_id' => ['required', 'integer', 'exists:countries,id'],
|
||||
'notes' => ['nullable', 'string'],
|
||||
'active' => ['sometimes', 'boolean'],
|
||||
'supplier_category_ids' => ['nullable', 'array'],
|
||||
'supplier_category_ids.*' => ['integer', 'exists:supplier_categories,id'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'active' => $this->boolean('active'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue