LanguageForm::getUpdateRules()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php namespace Distilleries\Expendable\Http\Forms\Language;
2
3
use Distilleries\Expendable\Helpers\StaticLabel;
4
use Distilleries\FormBuilder\FormValidator;
5
6
class LanguageForm extends FormValidator {
7
8
    public static $rules = [
9
        'libelle'     => 'required',
10
        'iso'         => 'required|unique:languages',
11
        'not_visible' => 'required|integer',
12
        'is_default'  => 'required|integer',
13
        'status'      => 'required|integer'
14
    ];
15
16 8
    public function buildForm()
17
    {
18
        $this
19 8
            ->add('id', 'hidden')
20 8
            ->add('libelle', 'text')
21 8
            ->add('iso', 'text')
22 8
            ->add('not_visible', 'choice', [
23 8
                'choices'     => StaticLabel::yesNo(),
24 8
                'empty_value' => '-',
25 8
                'validation'  => 'required',
26 8
                'label'       => trans('expendable::form.is_visible_for_customer')
27
            ])
28 8
            ->add('is_default', 'choice', [
29 8
                'choices'     => StaticLabel::yesNo(),
30 8
                'empty_value' => '-',
31 8
                'validation'  => 'required',
32 8
                'label'       => trans('expendable::form.default_language')
33
            ])
34 8
            ->add('status', 'choice', [
35 8
                'choices'     => StaticLabel::status(),
36 8
                'empty_value' => '-',
37 8
                'validation'  => 'required',
38 8
                'label'       => trans('expendable::form.status')
39
            ]);
40
41 8
        $this->addDefaultActions();
42
    }
43
44 4
    protected function getUpdateRules()
45
    {
46 4
        $key                  = \Request::get($this->model->getKeyName());
47 4
        static::$rules['iso'] = 'required|unique:languages,iso,'.$key;
48
49 4
        return parent::getUpdateRules();
50
    }
51
}