54 lines
1.5 KiB
PHP
54 lines
1.5 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Requests\Api\V1\BomResolver;
|
||
|
|
|
||
|
|
use Illuminate\Foundation\Http\FormRequest;
|
||
|
|
|
||
|
|
class ResolvePreviewRequest extends FormRequest
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Determine if the user is authorized to make this request.
|
||
|
|
*/
|
||
|
|
public function authorize(): bool
|
||
|
|
{
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the validation rules that apply to the request.
|
||
|
|
*/
|
||
|
|
public function rules(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'input_parameters' => ['required', 'array', 'min:1'],
|
||
|
|
'input_parameters.*' => ['required'],
|
||
|
|
'bom_template_id' => ['sometimes', 'integer', 'min:1'],
|
||
|
|
'include_calculated_values' => ['boolean'],
|
||
|
|
'include_bom_items' => ['boolean'],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get custom attribute names for validator errors.
|
||
|
|
*/
|
||
|
|
public function attributes(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'input_parameters' => __('validation.attributes.input_parameters'),
|
||
|
|
'bom_template_id' => __('validation.attributes.bom_template_id'),
|
||
|
|
'include_calculated_values' => __('validation.attributes.include_calculated_values'),
|
||
|
|
'include_bom_items' => __('validation.attributes.include_bom_items'),
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Prepare the data for validation.
|
||
|
|
*/
|
||
|
|
protected function prepareForValidation(): void
|
||
|
|
{
|
||
|
|
$this->merge([
|
||
|
|
'include_calculated_values' => $this->boolean('include_calculated_values', true),
|
||
|
|
'include_bom_items' => $this->boolean('include_bom_items', true),
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
}
|