Completed
Push — master ( 188ffb...31684b )
by Maxime
02:48
created

LanguageForm::buildForm()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 27
rs 8.8571
cc 1
eloc 21
nc 1
nop 0
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
    public function buildForm()
17
    {
18
        $this
19
            ->add('id', 'hidden')
20
            ->add('libelle', 'text')
21
            ->add('iso', 'text')
22
            ->add('not_visible', 'choice', [
23
                'choices'     => StaticLabel::yesNo(),
24
                'empty_value' => '-',
25
                'validation'  => 'required',
26
                'label'       => trans('expendable::form.is_visible_for_customer')
27
            ])
28
            ->add('is_default', 'choice', [
29
                'choices'     => StaticLabel::yesNo(),
30
                'empty_value' => '-',
31
                'validation'  => 'required',
32
                'label'       => trans('expendable::form.default_language')
33
            ])
34
            ->add('status', 'choice', [
35
                'choices'     => StaticLabel::status(),
36
                'empty_value' => '-',
37
                'validation'  => 'required',
38
                'label'       => trans('expendable::form.status')
39
            ]);
40
41
        $this->addDefaultActions();
42
    }
43
44 View Code Duplication
    protected function getUpdateRules()
45
    {
46
        $key                  = \Request::get($this->model->getKeyName());
47
        static::$rules['iso'] = 'required|unique:languages,iso,' . $key;
48
49
        return parent::getUpdateRules();
50
    }
51
}