|
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
|
|
|
} |