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

30 lines
726 B
PHP
Raw Normal View History

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