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