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