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

31 lines
663 B
PHP

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