66 lines
2.1 KiB
PHP
66 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class UpdateHarvestRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
// TODO: Implement authorization logic (check if user has permission to update harvests)
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'vineyard_row_id' => ['required', 'exists:vineyard_rows,id'],
|
|
'variety_variation_id' => ['required', 'exists:variety_variations,id'],
|
|
'weight' => ['required', 'numeric', 'min:0', 'max:99999.99'],
|
|
'sugar_content' => ['nullable', 'numeric', 'min:0', 'max:50'],
|
|
'date' => ['required', 'date', 'before_or_equal:today'],
|
|
'quality' => ['nullable', 'in:excellent,good,fair,poor'],
|
|
'grape_condition' => ['nullable', 'string', 'max:255'],
|
|
'notes' => ['nullable', 'string', 'max:1000'],
|
|
'weather_conditions' => ['nullable', 'string', 'max:500'],
|
|
'harvest_time' => ['nullable', 'date_format:H:i'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get custom messages for validator errors.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'date.before_or_equal' => 'The harvest date cannot be in the future.',
|
|
'harvest_time.date_format' => 'The harvest time must be in HH:MM format.',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get custom attribute names for validator errors.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'vineyard_row_id' => 'vineyard row',
|
|
'variety_variation_id' => 'variety variation',
|
|
'sugar_content' => 'sugar content (°NM)',
|
|
'harvest_time' => 'harvest time',
|
|
];
|
|
}
|
|
}
|