phpvms/app/Http/Requests/Acars/UpdateRequest.php

56 lines
2.0 KiB
PHP
Raw Normal View History

2018-01-31 01:36:22 +08:00
<?php
namespace App\Http\Requests\Acars;
use App\Contracts\FormRequest;
2018-01-31 01:36:22 +08:00
use App\Models\Pirep;
use Illuminate\Support\Facades\Auth;
2018-01-31 01:36:22 +08:00
class UpdateRequest extends FormRequest
{
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();
}
public function rules(): array
2018-01-31 01:36:22 +08:00
{
$rules = [
'airline_id' => 'nullable|exists:airlines,id',
'aircraft_id' => 'nullable|exists:aircraft,id',
'flight_number' => 'nullable',
'dpt_airport_id' => 'nullable',
'arr_airport_id' => 'nullable',
'route_code' => 'nullable',
'route_leg' => 'nullable',
'distance' => 'nullable|numeric',
'planned_distance' => 'nullable|numeric',
'block_time' => 'nullable|integer',
'flight_time' => 'nullable|integer',
2018-05-01 06:29:42 +08:00
'flight_type' => 'nullable',
'planned_flight_time' => 'nullable|integer',
'level' => 'nullable|numeric',
'zfw' => 'nullable|numeric',
'fuel_used' => 'nullable|numeric',
'block_fuel' => 'nullable|numeric',
'route' => 'nullable',
'notes' => 'nullable',
'source_name' => 'nullable|max:25',
'landing_rate' => 'nullable|numeric',
2018-05-02 09:58:05 +08:00
'block_off_time' => 'nullable',
'block_on_time' => 'nullable',
'created_at' => 'nullable',
2018-04-02 09:37:10 +08:00
'status' => 'nullable',
2018-04-26 00:56:05 +08:00
'score' => 'nullable|integer',
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;
}
}