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

SkillCrudRequest::authorize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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