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 FileRequest extends FormRequest
|
|
|
|
{
|
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 [
|
2019-11-06 00:44:31 +08:00
|
|
|
'distance' => 'required|numeric',
|
|
|
|
'flight_time' => 'required|integer',
|
|
|
|
'fuel_used' => 'required|numeric',
|
2019-12-03 07:27:58 +08:00
|
|
|
'block_time' => 'sometimes|integer',
|
|
|
|
'airline_id' => 'sometimes|exists:airlines,id',
|
|
|
|
'aircraft_id' => 'sometimes|exists:aircraft,id',
|
|
|
|
'flight_number' => 'sometimes',
|
|
|
|
'flight_type' => 'sometimes',
|
2020-02-28 00:37:05 +08:00
|
|
|
'dpt_airport_id' => 'sometimes',
|
|
|
|
'arr_airport_id' => 'sometimes',
|
2019-12-03 07:27:58 +08:00
|
|
|
'route_code' => 'sometimes',
|
|
|
|
'route_leg' => 'sometimes',
|
|
|
|
'planned_distance' => 'sometimes|numeric',
|
|
|
|
'planned_flight_time' => 'sometimes|integer',
|
|
|
|
'level' => 'sometimes|numeric',
|
|
|
|
'zfw' => 'sometimes|numeric',
|
|
|
|
'block_fuel' => 'sometimes|numeric',
|
|
|
|
'route' => 'sometimes',
|
|
|
|
'notes' => 'sometimes',
|
|
|
|
'source_name' => 'sometimes',
|
|
|
|
'score' => 'sometimes|integer',
|
|
|
|
'landing_rate' => 'sometimes|numeric',
|
|
|
|
'block_off_time' => 'sometimes|date',
|
|
|
|
'block_on_time' => 'sometimes|date',
|
|
|
|
'created_at' => 'sometimes|date',
|
2018-03-14 23:34:41 +08:00
|
|
|
|
2018-08-27 00:40:04 +08:00
|
|
|
// See if the fare objects are included and formatted properly
|
|
|
|
'fares' => 'nullable|array',
|
|
|
|
'fares.*.id' => 'required',
|
|
|
|
'fares.*.count' => 'required|numeric',
|
2018-01-29 01:12:13 +08:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|