Settings page
A workspace's settings, a section to a form: its name, address, logo and time zone; the preferences everyone shares; what new members are told about and how, as a grid of events and channels; and, apart from the rest, the way to delete it. Each section saves on its own, with a save bar that comes up when it has changes, and a toast says when it has. The settings pages sit beside each other in a nav of their own, which the team members, roles, API keys and billing blocks share.


A block, not a component: copy the views below into your app. It is a page in the sidebar shell, which assumes the base layout.
What it shows
-
The settings nav, beside the page from
lgand a row of navigation tabs above it on a phone: five links, the current page marked from the route. It is its own view,components/settings/nav, which the other four settings blocks draw too. -
One form per section, each in a panel, each posting to its own route through its own Form Request into its own error bag. A mistake in General leaves Preferences as it was, and two sections never show each other's errors.
-
General: the name and address as inputs, the logo as an avatar upload with a square crop, and the time zone as a combobox, searchable as you type. The input has no prefix of its own, so the address the slug makes is said in its help.
-
Preferences: three switches, each with a line on what it does; the theme new members start with as radio cards; the first day of the week as a segmented control.
-
Notifications: what new members are told about, event by channel, as a table of checkboxes: a row header for every event and a column header for every channel, so a screen reader says both, and every box named in full as well ("Email members when they are mentioned").
-
A save bar per form: change a field and that section's save bar comes up, with Save and Discard; change it back and it goes.

-
Errors on the fields: the section's save bar stays up with "Nothing was saved", and each message is tied to its field:

-
Saved: a toast at the foot of the window, which goes by itself after five seconds. It is the shell's: the layout's toast region shows whatever
statuswas flashed:
-
The danger zone: deleting the workspace cannot be undone, so it is a modal that asks for the address to be typed, its Delete disabled until it matches, rather than a confirm button (see which confirmation). It does not close on a click outside or on Escape; Cancel is the way out.

Built from
- Page header: the title and its line
- Nav item and Tabs: the settings nav, beside the page and above it on a phone
- Panel: each section
- Input: the name, the address, the typed confirmation
- Avatar upload: the logo
- Combobox: the time zone
- Switch, Radio cards and Segmented control: the preferences
- Table and Checkbox: the notifications grid
- Save bar: one per form
- Button and Modal: deleting the workspace
The markup
resources/views/settings/workspace.blade.php
{{--
The workspace's settings: one form per section, each posting to its own
route and validated by its own Form Request into its own error bag, so
a mistake in one section never empties another. Each form has its own
save bar. The controller passes $workspace; a save redirects back with
`status` flashed, which the toast says.
--}}
@php
$general = $errors->general;
$timezones = [
'Europe/London' => 'London (GMT+0)',
'Europe/Dublin' => 'Dublin (GMT+0)',
'Europe/Lisbon' => 'Lisbon (GMT+0)',
'Atlantic/Reykjavik' => 'Reykjavík (GMT+0)',
'Europe/Oslo' => 'Oslo (GMT+1)',
'Europe/Paris' => 'Paris (GMT+1)',
'Europe/Helsinki' => 'Helsinki (GMT+2)',
'America/Halifax' => 'Halifax (GMT−4)',
'America/New_York' => 'New York (GMT−5)',
];
@endphp
<x-layouts.app title="Workspace settings">
<div class="flex flex-col gap-6 lg:flex-row lg:gap-10">
<x-settings.nav />
<div class="flex min-w-0 flex-1 flex-col gap-6">
<x-ds::page-header title="Workspace" description="The name, address and defaults everyone at {{ $workspace['name'] }} shares." />
<form id="general" method="POST" action="{{ route('settings.general.update') }}" enctype="multipart/form-data">
@csrf
@method('PUT')
<x-ds::panel title="General" body="plain">
<div class="flex max-w-xl flex-col gap-5">
<x-ds::input id="name" name="name" label="Workspace name" required :value="old('name', $workspace['name'])" :error="$general->first('name')" />
{{-- The input has no prefix of its own, so the address it makes is said in the help. --}}
<x-ds::input id="slug" name="slug" label="Address" required :value="old('slug', $workspace['slug'])" :help="'Your workspace is at pebblework.example/'.$workspace['slug'].'. Old links keep working for 30 days after a change.'" :error="$general->first('slug')" />
<x-ds::avatar-upload name="logo" label="Logo" help="Square, at least 256 pixels. Shown in emails and on shared pages." shape="square" :src="$workspace['logo']" :alt="$workspace['name']" :outputSize="256" outputType="image/png" :error="$general->first('logo')" />
<x-ds::combobox name="timezone" label="Time zone" help="Due dates and the end of each cycle follow it." :options="$timezones" :value="old('timezone', $workspace['timezone'])" :error="$general->first('timezone')" />
</div>
</x-ds::panel>
<x-ds::save-bar :error="$general->any() ? 'Nothing was saved. Check the fields marked in red.' : null" />
</form>
<form id="preferences" method="POST" action="{{ route('settings.preferences.update') }}">
@csrf
@method('PUT')
<x-ds::panel title="Preferences" body="plain">
<div class="flex flex-col gap-6">
<div class="flex max-w-xl flex-col gap-4">
<x-ds::switch name="public_links" label="Public issue links" help="Anyone with an issue’s link can read it. Only members can comment." :checked="$workspace['public_links']" />
<x-ds::switch name="members_invite" label="Members can invite people" help="Otherwise only admins and the owner can." :checked="$workspace['members_invite']" />
<x-ds::switch name="digest" label="Weekly digest" help="A summary of the week’s issues, emailed on Monday morning." :checked="$workspace['digest']" />
</div>
<x-ds::radio-cards name="theme" label="Theme for new members" help="Each person can change their own." :columns="3">
<x-ds::radio-card value="light" title="Light" description="Dark text on white." :checked="$workspace['theme'] === 'light'" />
<x-ds::radio-card value="dark" title="Dark" description="Light text on near-black." :checked="$workspace['theme'] === 'dark'" />
<x-ds::radio-card value="system" title="Match the device" description="Follows each person’s system setting." :checked="$workspace['theme'] === 'system'" />
</x-ds::radio-cards>
<x-ds::segmented-control name="week_start" label="Weeks start on">
@foreach (['monday' => 'Monday', 'sunday' => 'Sunday', 'saturday' => 'Saturday'] as $day => $name)
<x-ds::segment :value="$day" :checked="$workspace['week_start'] === $day">{{ $name }}</x-ds::segment>
@endforeach
</x-ds::segmented-control>
</div>
</x-ds::panel>
<x-ds::save-bar />
</form>
<form id="notification-defaults" method="POST" action="{{ route('settings.notification-defaults.update') }}">
@csrf
@method('PUT')
<x-ds::panel title="Notifications" body="plain">
<p class="mb-4 max-w-prose text-body text-fg-muted">What new members are told about, and how. Each person can change their own later.</p>
<x-settings.notification-matrix :notify="$workspace['notify']" />
</x-ds::panel>
<x-ds::save-bar />
</form>
{{-- A modal, not a confirm button: this cannot be undone, so it asks for the address to be typed. --}}
<div x-data="{ deleteOpen: @js($errors->deleteWorkspace->any()), typed: '' }">
<x-ds::panel title="Danger zone" icon="exclamation-triangle" iconTone="danger" body="plain">
<div class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
<div class="max-w-prose">
<p class="text-body font-medium text-fg">Delete this workspace</p>
<p class="text-body text-fg-muted">Every project, issue and comment goes with it, for all 9 members. This cannot be undone.</p>
</div>
<x-ds::button variant="danger" aria-haspopup="dialog" x-on:click="deleteOpen = true" class="shrink-0">Delete workspace</x-ds::button>
</div>
</x-ds::panel>
<x-ds::modal open="deleteOpen" title="Delete {{ $workspace['name'] }}?" description="Every project, issue and comment is deleted for everyone, at once. This cannot be undone." size="sm" :dismissible="false">
<form id="delete-workspace" method="POST" action="{{ route('workspace.destroy') }}">
@csrf
@method('DELETE')
<x-ds::input id="confirm" name="confirm" label="Type {{ $workspace['slug'] }} to confirm" autocomplete="off" x-model="typed" :error="$errors->deleteWorkspace->first('confirm')" />
</form>
<x-slot:footer>
<x-ds::button variant="ghost" size="sm" x-on:click="deleteOpen = false; typed = ''">Cancel</x-ds::button>
<x-ds::button type="submit" form="delete-workspace" variant="danger" size="sm" :disabled="true" x-bind:disabled="typed !== '{{ $workspace['slug'] }}'">Delete workspace</x-ds::button>
</x-slot:footer>
</x-ds::modal>
</div>
</div>
</div>
</x-layouts.app>
resources/views/components/settings/notification-matrix.blade.php
{{--
The notification defaults, event by channel: a real table, so a screen
reader reads each box with its row and column, and each box also
carries the whole question as its own name. $notify is event => the
channels that are on.
The package's table draws its own head from `columns`, which cannot
hold a row header, so the head and body are written here; the table
gives the box, the border and the scroll on a narrow screen.
--}}
@props(['notify'])
@php
$channels = ['email' => 'Email', 'push' => 'Push', 'app' => 'In app'];
$events = [
'assigned' => ['Assigned an issue', 'when they are assigned an issue'],
'mentioned' => ['Mentioned', 'when they are mentioned'],
'comment' => ['A comment on an issue they follow', 'about comments on issues they follow'],
'status' => ['An issue they follow changes status', 'when an issue they follow changes status'],
'cycle' => ['A cycle is ending', 'when a cycle is ending'],
];
$how = ['email' => 'Email members', 'push' => 'Send a push notification', 'app' => 'Tell members in the app'];
@endphp
<x-ds::table label="Notifications new members get">
<thead class="bg-surface-subtle">
<tr>
<th scope="col" class="px-4 py-3 text-left text-overline uppercase text-fg-muted">Event</th>
@foreach ($channels as $channel)
<th scope="col" class="whitespace-nowrap px-2 py-3 text-center text-overline uppercase text-fg-muted sm:w-28 sm:px-4">{{ $channel }}</th>
@endforeach
</tr>
</thead>
<tbody class="divide-y divide-divider">
@foreach ($events as $event => [$title, $when])
<x-ds::table-row :hover="false">
<th scope="row" class="px-4 py-3 text-left text-body font-normal text-fg">{{ $title }}</th>
@foreach ($channels as $channel => $heading)
{{-- Narrower on a phone, so the events keep the room. --}}
<x-ds::table-cell align="center" class="max-sm:px-2">
<x-ds::checkbox
:name="'notify['.$event.'][]'"
:value="$channel"
:label="$how[$channel].' '.$when"
:hideLabel="true"
:checked="in_array($channel, $notify[$event] ?? [], true)"
class="justify-center"
/>
</x-ds::table-cell>
@endforeach
</x-ds::table-row>
@endforeach
</tbody>
</x-ds::table>
resources/views/components/settings/nav.blade.php
{{--
The settings pages, beside the page on a desktop and as a row of tabs
above it on a phone. Both are links, so the current page is marked
from the route and the nav works with no script. Only one of the two
is shown at a time, so a screen reader meets one nav.
--}}
@php
$pages = [
'settings.workspace' => 'Workspace',
'settings.members' => 'Members',
'settings.roles' => 'Roles and permissions',
'settings.api-keys' => 'API keys',
'settings.billing' => 'Billing',
];
@endphp
<div class="lg:w-48 lg:shrink-0">
<nav aria-label="Settings" class="flex flex-col gap-0.5 max-lg:hidden lg:sticky lg:top-20">
@foreach ($pages as $route => $label)
<x-ds::nav-item :href="route($route)" :label="$label" :active="request()->routeIs($route)" />
@endforeach
</nav>
<x-ds::tabs label="Settings" :navigation="true" class="lg:hidden">
@foreach ($pages as $route => $label)
<x-ds::tab :href="route($route)" :active="request()->routeIs($route)">{{ $label }}</x-ds::tab>
@endforeach
</x-ds::tabs>
</div>
Wire it up
The routes
The settings nav links five pages; the other four are the team members, roles, API keys and billing blocks.
use App\Http\Controllers\WorkspaceSettingsController;
Route::middleware('auth')->prefix('settings')->group(function () {
Route::get('workspace', [WorkspaceSettingsController::class, 'show'])->name('settings.workspace');
Route::put('workspace', [WorkspaceSettingsController::class, 'general'])->name('settings.general.update');
Route::put('workspace/preferences', [WorkspaceSettingsController::class, 'preferences'])->name('settings.preferences.update');
Route::put('workspace/notifications', [WorkspaceSettingsController::class, 'notifications'])->name('settings.notification-defaults.update');
Route::delete('workspace', [WorkspaceSettingsController::class, 'destroy'])->name('workspace.destroy');
});
A Form Request per section
Each names its own error bag with $errorBag, which is what the view reads
($errors->general, $errors->deleteWorkspace). The workspace here is the
signed-in person's current team; the authorize checks are your own
policies.
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class UpdateGeneralSettings extends FormRequest
{
protected $errorBag = 'general';
public function authorize(): bool
{
return $this->user()->can('update', $this->user()->currentTeam);
}
public function rules(): array
{
return [
'name' => ['required', 'string', 'max:80'],
'slug' => ['required', 'lowercase', 'alpha_dash:ascii', 'max:40', Rule::unique('teams', 'slug')->ignore($this->user()->currentTeam)],
'logo' => ['nullable', 'image', 'max:2048'],
'timezone' => ['required', 'timezone'],
];
}
public function messages(): array
{
return [
'name.required' => 'Give the workspace a name.',
'slug.*' => 'Use lower-case letters, numbers and dashes, like tidewater-ferries.',
];
}
}
The other three, in files of their own, with the same authorize:
class UpdatePreferences extends FormRequest
{
protected $errorBag = 'preferences';
public function rules(): array
{
return [
'public_links' => ['required', 'boolean'],
'members_invite' => ['required', 'boolean'],
'digest' => ['required', 'boolean'],
'theme' => ['required', Rule::in(['light', 'dark', 'system'])],
'week_start' => ['required', Rule::in(['monday', 'sunday', 'saturday'])],
];
}
}
class UpdateNotificationDefaults extends FormRequest
{
protected $errorBag = 'notifications';
public function rules(): array
{
return [
'notify' => ['array'],
'notify.*' => ['array'],
'notify.*.*' => [Rule::in(['email', 'push', 'app'])],
];
}
}
class DeleteWorkspace extends FormRequest
{
protected $errorBag = 'deleteWorkspace';
public function rules(): array
{
return ['confirm' => ['required', Rule::in([$this->user()->currentTeam->slug])]];
}
public function messages(): array
{
return ['confirm.*' => 'Type the address exactly as it is shown.'];
}
}
The controller
namespace App\Http\Controllers;
use App\Http\Requests\DeleteWorkspace;
use App\Http\Requests\UpdateGeneralSettings;
use App\Http\Requests\UpdateNotificationDefaults;
use App\Http\Requests\UpdatePreferences;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
class WorkspaceSettingsController
{
public function show(Request $request)
{
$team = $request->user()->currentTeam;
return view('settings.workspace', ['workspace' => [
...$team->only('name', 'slug', 'timezone', 'public_links', 'members_invite', 'digest', 'theme', 'week_start'),
'logo' => $team->logo_path ? Storage::url($team->logo_path) : null,
'notify' => $team->notification_defaults ?? [], // a json column, cast to array
]]);
}
public function general(UpdateGeneralSettings $request)
{
$team = $request->user()->currentTeam;
$team->fill($request->safe()->only('name', 'slug', 'timezone'));
// The avatar upload posts the cropped picture as `logo`, or
// `logo_remove` = 1 when Remove was pressed.
if ($request->hasFile('logo')) {
$team->logo_path = $request->file('logo')->store('logos', 'public');
} elseif ($request->boolean('logo_remove')) {
$team->logo_path = null;
}
$team->save();
return back()->with('status', 'Workspace details saved.');
}
public function preferences(UpdatePreferences $request)
{
// Each switch posts 0 or 1 (a hidden input carries the 0), so a
// switch turned off is a 0, not a missing key.
$request->user()->currentTeam->update($request->validated());
return back()->with('status', 'Preferences saved.');
}
public function notifications(UpdateNotificationDefaults $request)
{
// An event with every box off posts nothing: read the events you
// know, not the ones that arrived.
$defaults = collect(['assigned', 'mentioned', 'comment', 'status', 'cycle'])
->mapWithKeys(fn ($event) => [$event => $request->input("notify.{$event}", [])]);
$request->user()->currentTeam->update(['notification_defaults' => $defaults]);
return back()->with('status', 'Notification defaults saved.');
}
public function destroy(DeleteWorkspace $request)
{
$request->user()->currentTeam->delete();
return to_route('home');
}
}
Each save redirects back with status flashed, and the shell's layout says
it: its toast region takes
:flash="session('status')", is drawn on every load, and adds the toast
once Alpine has started: a live region announces only what arrives after
it, so a toast that came with the page would be silent. If your layout is
not one of the shell blocks, give its region the same flash.
Live, with Livewire
A section as a Livewire component keeps the same markup, with wire:model
on the fields and the save bar told when the form is dirty, since
wire:model fields post nothing for it to compare. Livewire's
wire:dirty.attr sets the attribute it reads:
namespace App\Livewire;
use Illuminate\Validation\Rule;
use Livewire\Component;
use Livewire\WithFileUploads;
class GeneralSettings extends Component
{
use WithFileUploads;
public string $name = '';
public string $slug = '';
public string $timezone = '';
public $logo;
public function mount(): void
{
$this->fill(auth()->user()->currentTeam->only('name', 'slug', 'timezone'));
}
public function save(): void
{
$team = auth()->user()->currentTeam;
$this->validate([
'name' => ['required', 'max:80'],
'slug' => ['required', 'lowercase', 'alpha_dash:ascii', Rule::unique('teams', 'slug')->ignore($team)],
'timezone' => ['required', 'timezone'],
'logo' => ['nullable', 'image', 'max:2048'],
]);
$team->update([
...$this->only('name', 'slug', 'timezone'),
...($this->logo ? ['logo_path' => $this->logo->store('logos', 'public')] : []),
]);
$this->reset('logo');
$this->dispatch('saved', message: 'Workspace details saved.');
}
public function render()
{
return view('livewire.general-settings', [
'timezones' => ['Europe/London' => 'London (GMT+0)', 'Europe/Oslo' => 'Oslo (GMT+1)'],
]);
}
}
{{-- resources/views/livewire/general-settings.blade.php --}}
<form wire:submit="save">
<x-ds::panel title="General" body="plain">
<div class="flex max-w-xl flex-col gap-5">
<x-ds::input name="name" label="Workspace name" wire:model="name" :error="$errors->first('name')" />
<x-ds::input name="slug" label="Address" wire:model="slug" :error="$errors->first('slug')" />
<x-ds::avatar-upload name="logo" label="Logo" shape="square" wire:model="logo" :error="$errors->first('logo')" />
<x-ds::input as="select" name="timezone" label="Time zone" wire:model="timezone" :error="$errors->first('timezone')">
@foreach ($timezones as $zone => $label)
<option value="{{ $zone }}">{{ $label }}</option>
@endforeach
</x-ds::input>
</div>
</x-ds::panel>
<x-ds::save-bar :dirty="false" wire:dirty.attr="data-ds-dirty" x-on:discard="$wire.$refresh()"
:error="$errors->any() ? 'Nothing was saved. Check the fields marked in red.' : null" />
</form>
- The time zone is a native select here: the combobox posts
through a hidden input that its own Alpine writes, and passes no
wire:modelon to it. - Discard resets the form natively and then dispatches
discard;$wire.$refresh()puts the server's values back in the bound fields. savedis yours to show: listen for it on the page (x-on:saved.window) and add a toast to the region, as toast shows.
Phone, keyboard, no script
- Phone: the settings nav becomes navigation tabs above the page, scrolling sideways when they do not fit; the radio cards stack; the notifications grid keeps its four columns, with headers that do not wrap, inside the table's own sideways scroll. Each section keeps the room under it that its save bar needs.
- Keyboard: Tab runs through each section's fields and then, once it is up, its save bar's Discard and Save; a hidden save bar takes no Tab stop. A switch is Space, the radio cards and the segmented control are arrow keys, and each notification box is a Tab stop of its own, named in full. Delete workspace opens the modal with focus inside it; Tab stays in it, and Cancel puts focus back on the button.
- No script: every form posts. The save bars are a plain Save and
Discard at the end of each form, always shown; the switches, radio cards,
segmented control and boxes are native controls; the logo is a plain file
input with a Remove box. The time zone needs Alpine, as the combobox
does: without it the form posts the zone it was drawn with, and it cannot
be changed (use
ds::input as="select"if that matters). Deleting the workspace needs Alpine, as the modal does, and so does the toast, so a page that must work with no script also printssession('status')in the page.
From the package repo: edit this page on GitHub.