mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 15:07:49 +00:00
feat(#20): preference: assign mirror device id to auto joined devices
This commit is contained in:
parent
b4dfb1673f
commit
8d7a53b888
8 changed files with 138 additions and 2 deletions
|
|
@ -66,7 +66,7 @@
|
|||
<flux:menu.separator/>
|
||||
|
||||
<flux:menu.radio.group>
|
||||
<flux:menu.item href="/settings/profile" wire:navigate icon="cog">Settings</flux:menu.item>
|
||||
<flux:menu.item href="/settings/preferences" wire:navigate icon="cog">Settings</flux:menu.item>
|
||||
</flux:menu.radio.group>
|
||||
|
||||
<flux:menu.separator/>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<div class="flex items-start max-md:flex-col">
|
||||
<div class="mr-10 w-full pb-4 md:w-[220px]">
|
||||
<flux:navlist>
|
||||
<flux:navlist.item href="{{ route('settings.preferences') }}" wire:navigate>Preferences</flux:navlist.item>
|
||||
<flux:navlist.item href="{{ route('settings.profile') }}" wire:navigate>Profile</flux:navlist.item>
|
||||
<flux:navlist.item href="{{ route('settings.password') }}" wire:navigate>Password</flux:navlist.item>
|
||||
<flux:navlist.item href="{{ route('settings.appearance') }}" wire:navigate>Appearance</flux:navlist.item>
|
||||
|
|
|
|||
63
resources/views/livewire/settings/preferences.blade.php
Normal file
63
resources/views/livewire/settings/preferences.blade.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Device;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Livewire\Volt\Component;
|
||||
|
||||
new class extends Component {
|
||||
public ?int $assign_new_device_id = null;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->assign_new_device_id = Auth::user()->assign_new_device_id;
|
||||
}
|
||||
|
||||
public function updatePreferences(): void
|
||||
{
|
||||
$validated = $this->validate([
|
||||
'assign_new_device_id' => [
|
||||
'nullable',
|
||||
Rule::exists('devices', 'id')->where(function ($query) {
|
||||
$query->where('user_id', Auth::id())
|
||||
->whereNull('mirror_device_id');
|
||||
}),
|
||||
],
|
||||
]);
|
||||
|
||||
Auth::user()->update($validated);
|
||||
|
||||
$this->dispatch('profile-updated');
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<section class="w-full">
|
||||
@include('partials.settings-heading')
|
||||
|
||||
<x-settings.layout heading="Preferences" subheading="Update your preferences">
|
||||
<form wire:submit="updatePreferences" class="my-6 w-full space-y-6">
|
||||
<flux:select wire:model="assign_new_device_id" label="Auto-Joined Devices should mirror">
|
||||
<flux:select.option value="">None</flux:select.option>
|
||||
@foreach(auth()->user()->devices->where('mirror_device_id', null) as $device)
|
||||
<flux:select.option value="{{ $device->id }}">
|
||||
{{ $device->name }} ({{ $device->friendly_id }})
|
||||
</flux:select.option>
|
||||
@endforeach
|
||||
</flux:select>
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="flex items-center justify-end">
|
||||
<flux:button variant="primary" type="submit" class="w-full">{{ __('Save') }}</flux:button>
|
||||
</div>
|
||||
|
||||
<x-action-message class="me-3" on="profile-updated">
|
||||
{{ __('Saved.') }}
|
||||
</x-action-message>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</x-settings.layout>
|
||||
</section>
|
||||
Loading…
Add table
Add a link
Reference in a new issue