Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
FlyShareRequest
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 3
12
0.00% covered (danger)
0.00%
0 / 1
 authorize
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 failedAuthorization
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 rules
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Http\Requests;
4
5use Illuminate\Auth\Access\AuthorizationException;
6use Illuminate\Foundation\Http\FormRequest;
7
8class FlyShareRequest extends FormRequest
9{
10    /**
11     * Determine if the user is authorized to make this request.
12     */
13    public function authorize(): bool
14    {
15        return ! in_array($this->user()->email, $this->emails ?? []);
16    }
17
18    /**
19     * Handle a failed authorization attempt.
20     *
21     *
22     * @throws \Illuminate\Auth\Access\AuthorizationException
23     */
24    protected function failedAuthorization(): void
25    {
26        throw new AuthorizationException("You can't share a flymsg with yourself");
27    }
28
29    /**
30     * Get the validation rules that apply to the request.
31     */
32    public function rules(): array
33    {
34        return [
35            'first_name' => 'required|string|max:255',
36            'last_name' => 'required|string|max:255',
37            'emails' => 'required|array',
38            'emails.*' => 'required|email',
39            'message' => 'string|nullable',
40        ];
41    }
42}