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

Manage   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 27
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A mount() 0 4 1
A update() 0 5 1
A updatedSelectedLang() 0 3 1
A render() 0 4 1
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