first change
This commit is contained in:
24
app/Livewire/ToggleSwitch.php
Normal file
24
app/Livewire/ToggleSwitch.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Livewire\Attributes\Validate;
|
||||
use Livewire\Component;
|
||||
|
||||
class ToggleSwitch extends Component
|
||||
{
|
||||
#[Validate('required', 'in:sidebar,cpm-sidebar')]
|
||||
public $sidebar;
|
||||
public function toggle($isChecked)
|
||||
{
|
||||
$this->sidebar = $isChecked ? config('app.sidebar.other') : config('app.sidebar.default');
|
||||
auth()->user()->update(['active_sidebar' => $this->sidebar]);
|
||||
flash()->success("Dashboard has been toggled!");
|
||||
$this->redirectRoute('dashboard');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.toggle-switch');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user