31 lines
666 B
PHP
31 lines
666 B
PHP
<?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]);
|
|
}
|
|
}
|
|
}
|