2018-01-29 01:12:13 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Acars;
|
|
|
|
|
2019-07-16 03:44:31 +08:00
|
|
|
use App\Contracts\FormRequest;
|
2018-01-29 01:12:13 +08:00
|
|
|
use App\Models\Pirep;
|
2019-11-06 00:44:31 +08:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
2018-01-29 01:12:13 +08:00
|
|
|
|
|
|
|
class PositionRequest extends FormRequest
|
|
|
|
{
|
2018-05-10 01:45:24 +08:00
|
|
|
/**
|
2019-11-06 00:44:31 +08:00
|
|
|
* Is the user allowed to do this?
|
2018-05-10 01:45:24 +08:00
|
|
|
*/
|
2019-11-06 00:44:31 +08:00
|
|
|
public function authorize(): bool
|
2018-01-29 01:12:13 +08:00
|
|
|
{
|
|
|
|
$pirep = Pirep::findOrFail($this->route('pirep_id'), ['user_id']);
|
|
|
|
return $pirep->user_id === Auth::id();
|
|
|
|
}
|
|
|
|
|
2019-11-06 00:44:31 +08:00
|
|
|
public function rules(): array
|
2018-01-29 01:12:13 +08:00
|
|
|
{
|
2020-03-29 01:03:52 +08:00
|
|
|
return [
|
2018-03-20 09:50:40 +08:00
|
|
|
'positions' => 'required|array',
|
|
|
|
'positions.*.lat' => 'required|numeric',
|
|
|
|
'positions.*.lon' => 'required|numeric',
|
2019-12-03 07:27:58 +08:00
|
|
|
'positions.*.status' => 'sometimes',
|
|
|
|
'positions.*.altitude' => 'sometimes|numeric',
|
|
|
|
'positions.*.heading' => 'sometimes|numeric|between:0,360',
|
|
|
|
'positions.*.vs' => 'sometimes',
|
|
|
|
'positions.*.gs' => 'sometimes',
|
|
|
|
'positions.*.transponder' => 'sometimes',
|
|
|
|
'positions.*.autopilot' => 'sometimes',
|
|
|
|
'positions.*.fuel' => 'sometimes|numeric',
|
|
|
|
'positions.*.fuel_flow' => 'sometimes|numeric',
|
|
|
|
'positions.*.log' => 'sometimes|nullable',
|
|
|
|
'positions.*.sim_time' => 'sometimes|date',
|
|
|
|
'positions.*.created_at' => 'sometimes|date',
|
2018-01-29 01:12:13 +08:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|