SendInvitationRequest::authorize()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 7
rs 9.4285
1
<?php
2
3
namespace Acacha\Users\Http\Requests;
4
5
use Auth;
6
use Illuminate\Foundation\Http\FormRequest;
7
8
/**
9
 * Class SendInvitationRequest.
10
 *
11
 * @package Acacha\Users\Http\Requests
12
 */
13
class SendInvitationRequest extends FormRequest
14
{
15
    /**
16
     * Determine if the user is authorized to make this request.
17
     *
18
     * @return bool
19
     */
20
    public function authorize()
21
    {
22
23
        if (config('users.users_can_invite_other_users')) return true;
24
        if (Auth::user()) return Auth::user()->can('send-user-invitations');
25
        return false;
26
    }
27
28
    /**
29
     * Get the validation rules that apply to the request.
30
     *
31
     * @return array
32
     */
33
    public function rules()
34
    {
35
        return [
36
            'email' => 'required|email|max:255|unique:users',
37
        ];
38
    }
39
}
40