ChampionshipRequest::authorize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

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
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace App\Http\Requests;
4
5
use App\Invite;
6
use App\Tournament;
7
use Illuminate\Support\Facades\Auth;
8
9
class ChampionshipRequest extends Request
10
{
11
12
    /**
13
     * Determine if the user is authorized to make this request.
14
     *
15
     * @return bool
16
     */
17 1
    public function authorize()
18
    {
19 1
        return true;
20
    }
21
22
    /**
23
     * Get the validation rules that apply to the request.
24
     *
25
     * @return array
26
     */
27 1
    public function rules()
28
    {
29
        return [
30 1
        ];
31
    }
32
33
    public function getInvite(Tournament $tournament)
34
    {
35
        if ($this->invite != 0)
36
            return Invite::findOrFail($this->invite);
37
38
        return Invite::where('code', 'open')
39
            ->where('email', Auth::user()->email)
40
            ->where('object_type', 'App\Tournament')
41
            ->where('object_id', $tournament->id)
42
            ->get();
43
    }
44
}
45