Completed
Push — feature/backpack ( 46736d...1e2264 )
by Chris
10:38 queued 03:46
created

SkillCrudRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 6 1
A authorize() 0 4 1
A messages() 0 6 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace App\Http\Requests;
4
5
use App\Http\Requests\Request;
0 ignored issues
show
Bug introduced by
The type App\Http\Requests\Request was not found. Did you mean Request? If so, make sure to prefix the type with \.
Loading history...
6
use Illuminate\Foundation\Http\FormRequest;
7
use Illuminate\Support\Facades\Auth;
8
9
class SkillCrudRequest extends FormRequest
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class SkillCrudRequest
Loading history...
10
{
11
    /**
12
     * Determine if the user is authorized to make this request.
13
     *
14
     * @return boolean
15
     */
16
    public function authorize() : bool
17
    {
18
        // Only allow updates if the user is a logged in Admin.
19
        return backpack_auth()->check();
20
    }
21
22
    /**
23
     * Get the validation rules that apply to the request.
24
     *
25
     * @return string[]
26
     */
27
    public function rules() : array
28
    {
29
        return [
30
            'name' => "required|unique_translation:skills,name,{$this->id}",
31
            'description' => 'required',
32
            'skill_type_id' => 'exists:skill_types,id'
33
        ];
34
    }
35
36
    /**
37
     * Get the validation messages that apply to the request.
38
     *
39
     * @return string[]
40
     */
41
    public function messages() : array
42
    {
43
        return [
44
            'name.required' => 'Please enter a Skill name.',
45
            'name.unique_translation' => 'A Skill with this name already exists.',
46
            'skill_type_id.exists' => 'Please use an existing Skill Type.'
47
        ];
48
    }
49
}
50