Passed
Push — master ( bcac8b...ca1b68 )
by Reza
03:47
created

Manage::mount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
4
namespace EasyPanel\Http\Livewire\Translation;
5
6
7
use Livewire\Component;
8
use EasyPanel\Services\LangManager;
9
10
class Manage extends Component
11
{
12
    public $selectedLang;
13
    public $texts;
14
15
    public function mount()
16
    {
17
        $this->selectedLang = (config('easy_panel.lang') ?? 'en').'_panel';
18
        $this->texts = LangManager::getTexts($this->selectedLang);
19
    }
20
21
    public function updatedSelectedLang($value)
22
    {
23
        $this->texts = LangManager::getTexts($value);
24
    }
25
26
    public function render()
27
    {
28
        return view('admin::livewire.translation.manage')
29
            ->layout('admin::layouts.app', ['title' => __('Translation')]);
30
    }
31
32
    public function update()
33
    {
34
        LangManager::updateLanguage($this->selectedLang, $this->texts);
35
36
        $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('UpdatedMessage', ['name' => __('Translation') ])]);
37
    }
38
}
39