2018-01-29 01:12:13 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Acars;
|
|
|
|
|
|
|
|
use App\Models\Pirep;
|
2018-02-21 12:33:09 +08:00
|
|
|
use Auth;
|
2018-01-29 01:12:13 +08:00
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class FileRequest
|
|
|
|
* @package App\Http\Requests\Acars
|
|
|
|
*/
|
|
|
|
class FileRequest extends FormRequest
|
|
|
|
{
|
|
|
|
public function authorize()
|
|
|
|
{
|
|
|
|
$pirep = Pirep::findOrFail($this->route('pirep_id'), ['user_id']);
|
2018-03-20 09:50:40 +08:00
|
|
|
|
2018-01-29 01:12:13 +08:00
|
|
|
return $pirep->user_id === Auth::id();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function rules()
|
|
|
|
{
|
|
|
|
$rules = [
|
2018-03-20 09:50:40 +08:00
|
|
|
'distance' => 'required|numeric',
|
|
|
|
'flight_time' => 'required|integer',
|
|
|
|
'fuel_used' => 'required|numeric',
|
|
|
|
|
2018-03-30 02:42:16 +08:00
|
|
|
'block_time' => 'nullable|integer',
|
2018-03-20 09:50:40 +08:00
|
|
|
'airline_id' => 'nullable|exists:airlines,id',
|
|
|
|
'aircraft_id' => 'nullable|exists:aircraft,id',
|
|
|
|
'flight_number' => 'nullable',
|
2018-05-01 06:29:42 +08:00
|
|
|
'flight_type' => 'nullable',
|
2018-03-20 09:50:40 +08:00
|
|
|
'dpt_airport_id' => 'nullable',
|
|
|
|
'arr_airport_id' => 'nullable',
|
|
|
|
'route_code' => 'nullable',
|
|
|
|
'route_leg' => 'nullable',
|
|
|
|
'planned_distance' => 'nullable|numeric',
|
|
|
|
'planned_flight_time' => 'nullable|integer',
|
|
|
|
'level' => 'nullable|numeric',
|
|
|
|
'zfw' => 'nullable|numeric',
|
|
|
|
'block_fuel' => 'nullable|numeric',
|
|
|
|
'route' => 'nullable',
|
|
|
|
'notes' => 'nullable',
|
2018-04-05 02:03:10 +08:00
|
|
|
'source_name' => 'nullable',
|
2018-04-26 00:56:05 +08:00
|
|
|
'score' => 'nullable|integer',
|
2018-03-20 09:50:40 +08:00
|
|
|
'landing_rate' => 'nullable|numeric',
|
2018-03-30 03:12:25 +08:00
|
|
|
'block_off_time' => 'nullable|date',
|
|
|
|
'block_on_time' => 'nullable|date',
|
2018-03-20 09:50:40 +08:00
|
|
|
'created_at' => 'nullable|date',
|
2018-03-14 23:34:41 +08:00
|
|
|
|
|
|
|
# See if the fare objects are included and formatted properly
|
2018-03-20 09:50:40 +08:00
|
|
|
'fares' => 'nullable|array',
|
|
|
|
'fares.*.id' => 'required',
|
|
|
|
'fares.*.count' => 'required|numeric',
|
2018-01-29 01:12:13 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
return $rules;
|
|
|
|
}
|
|
|
|
}
|