2018-01-31 01:36:22 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Acars;
|
|
|
|
|
2019-07-16 03:44:31 +08:00
|
|
|
use App\Contracts\FormRequest;
|
2018-01-31 01:36:22 +08:00
|
|
|
use App\Models\Pirep;
|
2019-11-06 00:44:31 +08:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
2018-01-31 01:36:22 +08:00
|
|
|
|
|
|
|
class UpdateRequest extends FormRequest
|
|
|
|
{
|
2019-11-06 00:44:31 +08:00
|
|
|
public function authorize(): bool
|
2018-01-31 01:36:22 +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-31 01:36:22 +08:00
|
|
|
{
|
|
|
|
$rules = [
|
2018-03-20 09:50:40 +08:00
|
|
|
'airline_id' => 'nullable|exists:airlines,id',
|
|
|
|
'aircraft_id' => 'nullable|exists:aircraft,id',
|
2019-12-03 07:27:58 +08:00
|
|
|
'flight_number' => 'sometimes|required|exists:flights,id',
|
|
|
|
'dpt_airport_id' => 'sometimes|required|size:4',
|
|
|
|
'arr_airport_id' => 'sometimes|required|size:4',
|
2018-03-20 09:50:40 +08:00
|
|
|
'route_code' => 'nullable',
|
|
|
|
'route_leg' => 'nullable',
|
2019-12-03 07:27:58 +08:00
|
|
|
'distance' => 'sometimes|numeric',
|
|
|
|
'planned_distance' => 'sometimes|numeric',
|
|
|
|
'block_time' => 'sometimes|integer',
|
|
|
|
'flight_time' => 'sometimes|integer',
|
2018-05-01 06:29:42 +08:00
|
|
|
'flight_type' => 'nullable',
|
2019-12-03 07:27:58 +08:00
|
|
|
'planned_flight_time' => 'sometimes|integer',
|
|
|
|
'level' => 'sometimes|numeric',
|
|
|
|
'zfw' => 'sometimes|numeric',
|
|
|
|
'fuel_used' => 'sometimes|numeric',
|
|
|
|
'block_fuel' => 'sometimes|numeric',
|
|
|
|
'route' => 'sometimes|nullable',
|
|
|
|
'notes' => 'sometimes|nullable',
|
|
|
|
'source_name' => 'sometimes|max:25',
|
|
|
|
'landing_rate' => 'sometimes|numeric',
|
|
|
|
'block_off_time' => 'sometimes|date',
|
|
|
|
'block_on_time' => 'sometimes|date',
|
|
|
|
'created_at' => 'sometimes|date',
|
|
|
|
'status' => 'sometimes',
|
2018-04-26 00:56:05 +08:00
|
|
|
'score' => 'nullable|integer',
|
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-31 01:36:22 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
return $rules;
|
|
|
|
}
|
|
|
|
}
|