lernschiff/app/Livewire/Settings/Index.php

46 lines
1.1 KiB
PHP

<?php
namespace App\Livewire\Settings;
use Illuminate\Contracts\View\View;
use Livewire\Attributes\Lazy;
use Livewire\Attributes\Layout;
use Livewire\Attributes\Url;
use Livewire\Component;
#[Layout('layouts.dashboard', ['active' => 'settings'])]
#[Lazy]
class Index extends Component
{
public static function placeholder(array $params = []): View
{
return view('components.skeleton.page', ['rows' => 4]);
}
#[Url(as: 'section', keep: true)]
public string $section = 'profile';
/** @var array<int,string> */
protected array $allowedSections = ['profile', 'language', 'security', 'notifications', 'danger'];
public function mount(): void
{
if (! in_array($this->section, $this->allowedSections, true)) {
$this->section = 'profile';
}
}
public function setSection(string $section): void
{
if (in_array($section, $this->allowedSections, true)) {
$this->section = $section;
}
}
public function render(): View
{
return view('livewire.settings.index');
}
}