gruene-seele/app/Http/Requests/Inventory/StoreSupplierRequest.php

39 lines
1.1 KiB
PHP

<?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'),
]);
}
}