Total Complexity | 7 |
Total Lines | 50 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class Manage extends Component |
||
10 | { |
||
11 | public $selectedLang; |
||
12 | public $texts; |
||
13 | public $language; |
||
14 | |||
15 | public function mount() |
||
19 | } |
||
20 | |||
21 | public function updatedSelectedLang($value) |
||
24 | } |
||
25 | |||
26 | public function render() |
||
30 | } |
||
31 | |||
32 | protected function getRules() |
||
33 | { |
||
34 | return [ |
||
35 | 'language' => 'required|min:2|max:10|string' |
||
36 | ]; |
||
37 | } |
||
38 | |||
39 | public function create() |
||
40 | { |
||
41 | $this->validate(); |
||
42 | try { |
||
43 | $lang = strtolower($this->language) . '_panel'; |
||
44 | File::copy(LangManager::getPath('en_panel'), LangManager::getPath($lang)); |
||
45 | |||
46 | $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('CreatedMessage', ['name' => __('Translation') ])]); |
||
47 | } catch (\Exception $exception){ |
||
48 | $this->dispatchBrowserEvent('show-message', ['type' => 'error', 'message' => $exception->getMessage()]); |
||
49 | } |
||
50 | |||
51 | $this->reset('language'); |
||
52 | } |
||
53 | |||
54 | public function update() |
||
59 | } |
||
60 | } |
||
61 |