CreateRequest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A failedAuthorization() 0 3 1
A authorize() 0 3 2
A rules() 0 7 1
1
<?php
2
3
namespace Innoflash\Events\Http\Requests\Guest;
4
5
use FaithGen\SDK\Helpers\Helper;
6
use Illuminate\Auth\Access\AuthorizationException;
7
use Illuminate\Foundation\Http\FormRequest;
8
use Innoflash\Events\Services\EventsService;
9
10
class CreateRequest extends FormRequest
11
{
12
    /**
13
     * Determine if the user is authorized to make this request.
14
     *
15
     * @param EventsService $eventsService
16
     * @return bool
17
     */
18
    public function authorize(EventsService $eventsService)
19
    {
20
        return $eventsService->getEvent() && $this->user()->can('view', $eventsService->getEvent());
21
    }
22
23
    /**
24
     * Get the validation rules that apply to the request.
25
     *
26
     * @return array
27
     */
28
    public function rules()
29
    {
30
        return [
31
            'title' => 'required|string|min:2|max:15',
32
            'name' => 'required|string',
33
            'event_id' => Helper::$idValidation,
34
            'image' => 'required|base64image',
35
        ];
36
    }
37
38
    public function failedAuthorization()
39
    {
40
        throw new AuthorizationException('You are not allowed to transact on this event');
41
    }
42
}
43