59 lines
1.6 KiB
PHP
59 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Modules\RestaurantDelivery\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class UpdateRiderLocationRequest 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 [
|
|
'latitude' => ['required', 'numeric', 'between:-90,90'],
|
|
'longitude' => ['required', 'numeric', 'between:-180,180'],
|
|
'speed' => ['nullable', 'numeric', 'min:0', 'max:500'],
|
|
'bearing' => ['nullable', 'numeric', 'min:0', 'max:360'],
|
|
'accuracy' => ['nullable', 'numeric', 'min:0'],
|
|
'altitude' => ['nullable', 'numeric'],
|
|
'timestamp' => ['nullable', 'date'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get custom attributes for validator errors.
|
|
*/
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'latitude' => 'location latitude',
|
|
'longitude' => 'location longitude',
|
|
'bearing' => 'direction bearing',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get the error messages for the defined validation rules.
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'latitude.between' => 'The latitude must be between -90 and 90 degrees.',
|
|
'longitude.between' => 'The longitude must be between -180 and 180 degrees.',
|
|
'bearing.max' => 'The bearing must be between 0 and 360 degrees.',
|
|
];
|
|
}
|
|
}
|