UserStoreRequest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 35
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 18 2
A authorize() 0 3 1
1
<?php
2
3
namespace App\Http\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
use Illuminate\Validation\Rule;
7
8
class UserStoreRequest extends FormRequest
9
{
10
    /**
11
     * Determine if the user is authorized to make this request.
12
     *
13
     * @return bool
14
     */
15
    public function authorize()
16
    {
17
        return true;
18
    }
19
20
    /**
21
     * Get the validation rules that apply to the request.
22
     *
23
     * @return array
24
     */
25
    public function rules()
26
    {
27
        $rules = [
28
            'name' => ['required', 'string', 'max:255'],
29
            'surname' => ['required', 'string', 'max:255'],
30
            'country_id' => ['required', 'string'],
31
            'email' => ['required','string','email','max:255', Rule::unique('users')->ignore($this->id)],
32
            'description' => ['required', 'string'],
33
            'accept_terms' => ['required'],
34
        ];
35
36
        if ($this->getMethod() == 'POST') { //store
37
            $rules += ['password' => 'required'];
38
        } else {
39
            // update
40
        }
41
42
        return $rules;
43
    }
44
}
45