2018-01-31 02:06:46 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Acars;
|
|
|
|
|
2019-07-16 03:44:31 +08:00
|
|
|
use App\Contracts\FormRequest;
|
2018-01-31 02:06:46 +08:00
|
|
|
use App\Models\Pirep;
|
2019-11-06 00:44:31 +08:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
2018-01-31 02:06:46 +08:00
|
|
|
|
|
|
|
class EventRequest extends FormRequest
|
|
|
|
{
|
2019-11-06 00:44:31 +08:00
|
|
|
public function authorize(): bool
|
2018-01-31 02:06:46 +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 02:06:46 +08:00
|
|
|
{
|
|
|
|
$rules = [
|
2018-03-20 09:50:40 +08:00
|
|
|
'events' => 'required|array',
|
|
|
|
'events.*.event' => 'required',
|
2020-02-09 02:29:34 +08:00
|
|
|
'events.*.lat' => 'sometimes|numeric',
|
|
|
|
'events.*.lon' => 'sometimes|numeric',
|
|
|
|
'events.*.created_at' => 'sometimes|date',
|
2018-01-31 02:06:46 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
return $rules;
|
|
|
|
}
|
|
|
|
}
|