DeleteRequest::failedAuthorization()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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