SolicitudeValueSearch::afterValidate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace roaresearch\yii2\formgenerator\roa\models;
4
5
use roaresearch\yii2\roa\ResourceSearch;
6
use yii\{base\Model, data\ActiveDataProvider};
7
8
/**
9
 * Contract to filter and sort collections of `SolicitudeValue` records.
10
 *
11
 * @author Angel (Faryshta) Guevara <[email protected]>
12
 */
13
class SolicitudeValueSearch extends SolicitudeValue implements ResourceSearch
14
{
15
    /**
16
     * @inhertidoc
17
     */
18 2
    protected function slugBehaviorConfig(): array
19
    {
20
        return [
21 2
            'idAttribute' => [],
22
            'parentSlugRelation' => 'solicitude',
23
            'resourceName' => 'value',
24
        ];
25
    }
26
27
    /**
28
     * @inhertidoc
29
     */
30 2
    public function rules()
31
    {
32
        return [
33 2
            [['solicitude_id'], 'required'],
34
            [['solicitude_id', 'section_id', 'field_id'], 'integer'],
35
            [['value'], 'safe'],
36
        ];
37
    }
38
39
    /**
40
     * @inhertidoc
41
     */
42 2
    public function search(
43
        array $params,
44
        ?string $formName = ''
45
    ): ?ActiveDataProvider {
46 2
        $this->load($params, $formName);
47 2
        if (!$this->validate()) {
48
            return null;
49
        }
50 2
        $this->checkAccess($params);
0 ignored issues
show
Bug introduced by
The method checkAccess() does not exist on roaresearch\yii2\formgen...s\SolicitudeValueSearch. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

50
        $this->/** @scrutinizer ignore-call */ 
51
               checkAccess($params);
Loading history...
51 2
        $class = get_parent_class();
52
53 2
        return new ActiveDataProvider([
54 2
            'query' => $class::find()->innerJoinWith(['solicitude'])
55 2
                ->andFilterWhere([
56 2
                    'solicitude_id' => $this->solicitude_id,
57 2
                    'section_id' => $this->section_id,
58 2
                    'field_id' => $this->field_id,
59 2
                ])->andFilterWhere(['like', 'value', $this->value])
60
        ]);
61
    }
62
63
    /**
64
     * @inhertidoc
65
     */
66 2
    public function afterValidate()
67
    {
68 2
        Model::afterValidate();
69 2
    }
70
}
71