1 | <?php |
||
2 | |||
3 | namespace App\Http\Livewire; |
||
4 | |||
5 | use App\Models\Setting; |
||
6 | use Illuminate\Support\Arr; |
||
7 | use Jantinnerezo\LivewireAlert\LivewireAlert; |
||
8 | use Livewire\Component; |
||
9 | |||
10 | class Settings extends Component |
||
11 | { |
||
12 | use LivewireAlert; |
||
13 | |||
14 | public $site_url = ''; |
||
15 | public $username = ''; |
||
16 | public $password = ''; |
||
17 | |||
18 | public function mount() |
||
19 | { |
||
20 | $settings = Setting::pluck('value', 'key')->toArray(); |
||
21 | $this->site_url = Arr::get($settings,'site_url'); |
||
22 | $this->username = Arr::get($settings,'username'); |
||
23 | } |
||
24 | |||
25 | public function render() |
||
26 | { |
||
27 | return view('components.settings'); |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @var array |
||
32 | */ |
||
33 | private function resetInputFields() |
||
0 ignored issues
–
show
|
|||
34 | { |
||
35 | $this->reset(['site_url', 'username', 'password']); |
||
36 | } |
||
37 | |||
38 | public function update() |
||
39 | { |
||
40 | $validatedDate = $this->validate([ |
||
41 | 'site_url' => 'required|url', |
||
42 | 'username' => 'required|string|max:191', |
||
43 | 'password' => 'required', |
||
44 | ]); |
||
45 | |||
46 | foreach($validatedDate as $key => $item) { |
||
47 | $setting = Setting::firstOrNew(['key' => $key]); |
||
48 | $setting->value = $item; |
||
49 | $setting->save(); |
||
50 | } |
||
51 | |||
52 | $this->alert('success', 'Settings Updated Successfully.'); |
||
53 | } |
||
54 | } |
||
55 |
This check looks for private methods that have been defined, but are not used inside the class.