DeleteRequest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 5
c 2
b 0
f 0
dl 0
loc 26
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 4 2
A rules() 0 3 1
A failedAuthorization() 0 3 1
1
<?php
2
3
namespace Innoflash\Events\Http\Requests;
4
5
use Illuminate\Auth\Access\AuthorizationException;
6
use Illuminate\Foundation\Http\FormRequest;
7
use Innoflash\Events\Services\EventsService;
8
9
class DeleteRequest extends FormRequest
10
{
11
    /**
12
     * Determine if the user is authorized to make this request.
13
     *
14
     * @return bool
15
     */
16
    public function authorize(EventsService $eventsService)
17
    {
18
        return $eventsService->getEvent()
19
            && $this->user()->can('delete', $eventsService->getEvent());
20
    }
21
22
    /**
23
     * Get the validation rules that apply to the request.
24
     *
25
     * @return array
26
     */
27
    public function rules()
28
    {
29
        return [];
30
    }
31
32
    public function failedAuthorization()
33
    {
34
        throw new AuthorizationException('You are not allowed to delete this event');
35
    }
36
}
37