Completed
Push — develop ( 2c1eef...362275 )
by Abdelrahman
02:00
created

AttributeFormRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 42
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 4 1
A withValidator() 0 5 1
A rules() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Attributes\Http\Requests\Adminarea;
6
7
use Rinvex\Support\Traits\Escaper;
8
use Illuminate\Foundation\Http\FormRequest;
9
10
class AttributeFormRequest extends FormRequest
11
{
12
    use Escaper;
13
14
    /**
15
     * Determine if the user is authorized to make this request.
16
     *
17
     * @return bool
18
     */
19
    public function authorize(): bool
20
    {
21
        return true;
22
    }
23
24
    /**
25
     * Configure the validator instance.
26
     *
27
     * @param \Illuminate\Validation\Validator $validator
28
     *
29
     * @return void
30
     */
31
    public function withValidator($validator): void
32
    {
33
        // Sanitize input data before submission
34
        $this->replace($this->escape($this->all()));
35
    }
36
37
    /**
38
     * Get the validation rules that apply to the request.
39
     *
40
     * @return array
41
     */
42
    public function rules(): array
43
    {
44
        $attribute = $this->route('attribute') ?? app('rinvex.attributes.attribute');
45
        $attribute->updateRulesUniques();
46
        $rules = $attribute->getRules();
47
        $rules['entities'] = 'nullable|array';
48
49
        return $rules;
50
    }
51
}
52