Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
FlyShareRequest
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 authorize
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 failedAuthorization
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 rules
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
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}