Team members
Who is in a workspace, and the ways in and out: invite people by email against a seat limit, follow up the invitations still waiting, change members' roles in place and save them together, and remove someone, with the owner protected from both. It is one of the settings pages, in the nav the settings page block draws.


A block, not a component: copy the views below into your app. It is a page in the sidebar shell, beside the settings nav from the settings page block.
What it shows
-
Invite people: a usage meter of the seats, pending invitations counted, over a form that takes several addresses at once in a tag input (each checked as an email as it is added, and no more of them than there are seats left) and the role they join as.
-
Pending invitations, each in a panel row, with Resend and a Revoke that asks first (confirm button). An expired one says so with a badge.
-
The members, searched and filtered by role in a filter bar that is a plain GET form, with the applied filters as chips that each remove one. The list is paged by the package's pagination view.
-
Roles changed in place: each member's role is a select in the table; change any and the save bar comes up, and Save roles posts them all at once. The owner's row has no select: the owner's role changes only by handing the ownership over, which is in its menu.
-
Each row's menu (dropdown): View profile; Remove from workspace, red, for everyone but the owner, whose Remove is disabled with the reason written in the row ("Cannot be removed"), not in a tooltip, since a disabled item cannot be focused to show one.
-
Remove asks first, in one modal for the whole table that the row's menu fills in: who, and where the form posts.

-
An invitation that fails comes back with the addresses as they were typed and the message on the field:

-
Every seat taken: the meter becomes an upgrade prompt with what the next plan adds, and the invite form is disabled until a seat is freed:

-
No match for the filters: an empty state with a way back to the whole list.

Built from
- Page header: the title and its line
- Panel: Invite people and Pending invitations, a row each
- Usage meter and Upgrade prompt: the seats, and the way to more when they run out
- Tag input, Select and Button: the invite form
- Badge: an expired invitation, a member's status
- Confirm button: Revoke
- Filter bar, with its chips, and Input: the search and the role filter
- Empty state: no member matches
- Table and Avatar: the members, a native select
per role (
ds::input as="select") - Dropdown: each row's menu
- Save bar: the roles
- Modal: removing a member
The markup
resources/views/settings/members.blade.php
{{--
Who is in the workspace: invite people, follow up the invitations, and
change roles or remove members. The controller passes $members (a
paginator of the filtered members), $invitations, $seats (used and
limit, pending invitations included) and $filters (q and role).
--}}
@php
$roles = ['admin' => 'Admin', 'editor' => 'Editor', 'viewer' => 'Viewer'];
$full = $seats['used'] >= $seats['limit'];
$invite = $errors->invite;
$filtered = array_filter($filters);
@endphp
<x-layouts.app title="Members">
<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="Members" description="Everyone who can sign in to Tidewater Ferries, and what they can do." />
<x-ds::panel title="Invite people" body="plain">
<div class="flex flex-col gap-5">
@if ($full)
<x-ds::upgrade-prompt
variant="inline"
label="Seats"
:used="$seats['used']"
:limit="$seats['limit']"
unit="seats"
plan="Business"
:href="route('billing.plans')"
:benefits="['Up to 100 seats', 'Single sign-on', 'Custom roles']"
>
Every seat is taken, pending invitations included. Remove someone or revoke an invitation to invite again.
</x-ds::upgrade-prompt>
@else
<x-ds::usage-meter label="Seats" :used="$seats['used']" :limit="$seats['limit']" unit="seats" />
@endif
<form method="POST" action="{{ route('invitations.store') }}" class="flex flex-col gap-4 md:flex-row md:items-start">
@csrf
<x-ds::tag-input
name="emails"
label="Email addresses"
help="Press Enter or comma after each address."
validate="email"
:max="$seats['limit'] - $seats['used']"
:value="old('emails', [])"
:error="$invite->first('emails')"
:disabled="$full"
class="min-w-0 flex-1"
/>
<x-ds::select name="role" label="Role" :options="$roles" :value="old('role', 'editor')" :disabled="$full" class="md:w-40" />
{{-- Down by a label's height, so the button lines up with the fields. --}}
<x-ds::button type="submit" icon="paper-airplane" :disabled="$full" class="self-start md:mt-7">Invite</x-ds::button>
</form>
</div>
</x-ds::panel>
@if ($invitations)
<x-ds::panel title="Pending invitations" :subtitle="count($invitations).' waiting for an answer'">
@foreach ($invitations as $invitation)
<x-ds::panel-row class="flex-wrap">
<div class="min-w-0 flex-1">
<p class="truncate font-medium text-fg">{{ $invitation['email'] }}</p>
<p class="text-meta text-fg-muted">{{ $roles[$invitation['role']] }} · {{ $invitation['sent'] }}</p>
</div>
@if ($invitation['expired'] ?? false)
<x-ds::badge tone="warning">Expired</x-ds::badge>
@endif
<div class="flex items-center gap-2">
<form method="POST" action="{{ route('invitations.resend', $invitation['id']) }}">
@csrf
<x-ds::button type="submit" variant="secondary" size="sm">Resend</x-ds::button>
</form>
<form method="POST" action="{{ route('invitations.destroy', $invitation['id']) }}">
@csrf
@method('DELETE')
<x-ds::confirm-button label="Revoke" question="Revoke this invitation?" variant="ghost" size="sm" />
</form>
</div>
</x-ds::panel-row>
@endforeach
</x-ds::panel>
@endif
<div x-data="{ removeOpen: false, removing: { name: '', action: '' } }" class="flex flex-col gap-4">
<h2 class="text-section text-fg">In the workspace</h2>
<form method="GET" action="{{ route('settings.members') }}">
<x-ds::filter-bar label="Filters" :active="count($filtered)" :resetHref="route('settings.members')">
<x-slot:search>
<x-ds::input type="search" name="q" aria-label="Search members" placeholder="Name or email" icon="magnifying-glass" :value="$filters['q']" />
</x-slot:search>
<x-ds::input as="select" name="role" aria-label="Role">
<option value="">Any role</option>
@foreach (['owner' => 'Owner', ...$roles] as $value => $name)
<option value="{{ $value }}" @selected($filters['role'] === $value)>{{ $name }}</option>
@endforeach
</x-ds::input>
<x-ds::button type="submit" variant="secondary">Apply</x-ds::button>
<x-slot:applied>
@if ($filters['q'])
<x-ds::filter-chip label="Search" :value="$filters['q']" :removeHref="request()->fullUrlWithoutQuery('q')" />
@endif
@if ($filters['role'])
<x-ds::filter-chip label="Role" :value="ucfirst($filters['role'])" :removeHref="request()->fullUrlWithoutQuery('role')" />
@endif
</x-slot:applied>
</x-ds::filter-bar>
</form>
@if ($members->isEmpty())
<x-ds::empty-state icon="user-group" :title="$filtered ? 'No members match' : 'No members yet'" :description="$filtered ? 'Try another name, or any role.' : 'Invite people above and they will show up here once they accept.'">
@if ($filtered)
<x-slot:action>
<x-ds::button variant="secondary" :href="route('settings.members')">Clear filters</x-ds::button>
</x-slot:action>
@endif
</x-ds::empty-state>
@else
{{-- Roles change in place and are saved together, with the save bar. --}}
<form id="member-roles" method="POST" action="{{ route('members.update') }}">
@csrf
@method('PUT')
<x-ds::table label="Members" :columns="['Member', ['label' => 'Role', 'width' => 'w-40'], 'Last active', 'Status', ['label' => '', 'width' => 'w-14']]">
@foreach ($members as $member)
@php $owner = $member['role'] === 'owner'; @endphp
<x-ds::table-row>
<x-ds::table-cell :rowHeader="true">
<div class="flex min-w-0 items-center gap-3">
<x-ds::avatar :name="$member['name']" size="sm" :decorative="true" />
<div class="min-w-0">
<p class="truncate">{{ $member['name'] }}</p>
<p class="truncate text-meta font-normal text-fg-muted">{{ $member['email'] }}</p>
</div>
</div>
</x-ds::table-cell>
<x-ds::table-cell>
@if ($owner)
{{-- Not a control: the owner's role changes only by handing ownership over. --}}
<p class="font-medium text-fg">Owner</p>
<p class="whitespace-nowrap text-meta text-fg-muted">Cannot be removed</p>
@else
<x-ds::input as="select" :name="'roles['.$member['id'].']'" :aria-label="'Role for '.$member['name']" class="min-w-32">
@foreach ($roles as $value => $name)
<option value="{{ $value }}" @selected(old('roles.'.$member['id'], $member['role']) === $value)>{{ $name }}</option>
@endforeach
</x-ds::input>
@endif
</x-ds::table-cell>
<x-ds::table-cell :nowrap="true">{{ $member['active'] }}</x-ds::table-cell>
<x-ds::table-cell :nowrap="true">
@if ($member['status'] === 'deactivated')
<x-ds::badge>Deactivated</x-ds::badge>
@else
<x-ds::badge tone="success" :dot="true">Active</x-ds::badge>
@endif
</x-ds::table-cell>
<x-ds::table-cell align="right">
<x-ds::dropdown>
<x-slot:trigger>
<x-ds::button variant="ghost" size="sm" icon="ellipsis-horizontal" :iconOnly="true" :aria-label="'Actions for '.$member['name']" />
</x-slot:trigger>
<x-ds::dropdown-item icon="user" :href="route('members.show', $member['id'])">View profile</x-ds::dropdown-item>
@if ($owner)
<x-ds::dropdown-item icon="key" :href="route('ownership.edit')">Transfer ownership</x-ds::dropdown-item>
<x-ds::dropdown-item icon="user-minus" :disabled="true">Remove from workspace</x-ds::dropdown-item>
@else
<x-ds::dropdown-item
icon="user-minus"
tone="danger"
aria-haspopup="dialog"
x-on:click="removing = {{ Js::from(['name' => $member['name'], 'action' => route('members.destroy', $member['id'])]) }}; removeOpen = true"
>Remove from workspace</x-ds::dropdown-item>
@endif
</x-ds::dropdown>
</x-ds::table-cell>
</x-ds::table-row>
@endforeach
</x-ds::table>
<x-ds::save-bar message="Role changes not saved yet" saveLabel="Save roles" />
</form>
{{ $members->withQueryString()->links('ds::pagination') }}
@endif
{{-- One dialog for every row: the row's menu says who, and where the form posts. --}}
<x-ds::modal open="removeOpen" title="Remove from workspace?" size="sm" :dismissible="false">
<p class="text-body text-fg-body">
<span x-text="removing.name" class="font-medium text-fg"></span> loses access at once and their seat is freed. Their issues and comments stay.
</p>
<form id="remove-member" method="POST" x-bind:action="removing.action">
@csrf
@method('DELETE')
</form>
<x-slot:footer>
<x-ds::button variant="ghost" size="sm" x-on:click="removeOpen = false">Cancel</x-ds::button>
<x-ds::button type="submit" form="remove-member" variant="danger" size="sm">Remove</x-ds::button>
</x-slot:footer>
</x-ds::modal>
</div>
</div>
</div>
</x-layouts.app>
Wire it up
The routes
use App\Http\Controllers\InvitationController;
use App\Http\Controllers\MemberController;
Route::middleware('auth')->prefix('settings')->group(function () {
Route::get('members', [MemberController::class, 'index'])->name('settings.members');
Route::put('members', [MemberController::class, 'update'])->name('members.update');
Route::get('members/{member}', [MemberController::class, 'show'])->name('members.show');
Route::delete('members/{member}', [MemberController::class, 'destroy'])->name('members.destroy');
Route::post('invitations', [InvitationController::class, 'store'])->name('invitations.store');
Route::post('invitations/{invitation}/resend', [InvitationController::class, 'resend'])->name('invitations.resend');
Route::delete('invitations/{invitation}', [InvitationController::class, 'destroy'])->name('invitations.destroy');
});
ownership.edit and billing.plans are pages of your own. Here a member
is a row of a memberships table (team_id, user_id, role,
deactivated_at), and the owner is the membership whose role is owner.
The list
namespace App\Http\Controllers;
use App\Http\Requests\UpdateMemberRoles;
use App\Models\Membership;
use Illuminate\Http\Request;
class MemberController
{
public function index(Request $request)
{
$team = $request->user()->currentTeam;
$filters = ['q' => (string) $request->query('q'), 'role' => (string) $request->query('role')];
$members = $team->memberships()->with('user')
->when($filters['q'], fn ($query, $q) => $query->whereHas('user', fn ($user) => $user
->where('name', 'like', "%{$q}%")->orWhere('email', 'like', "%{$q}%")))
->when($filters['role'], fn ($query, $role) => $query->where('role', $role))
->orderByRaw("role = 'owner' desc")->orderBy('created_at')
->paginate(10)
->through(fn (Membership $m) => [
'id' => $m->id,
'name' => $m->user->name,
'email' => $m->user->email,
'role' => $m->role,
'active' => $m->user->last_seen_at?->diffForHumans() ?? 'Never',
'status' => $m->deactivated_at ? 'deactivated' : 'active',
]);
$invitations = $team->invitations()->latest()->get()->map(fn ($i) => [
'id' => $i->id,
'email' => $i->email,
'role' => $i->role,
'sent' => $i->expires_at->isPast() ? 'Expired '.$i->expires_at->diffForHumans() : $i->created_at->diffForHumans(),
'expired' => $i->expires_at->isPast(),
])->all();
return view('settings.members', [
'members' => $members,
'invitations' => $invitations,
// Pending invitations hold a seat, so two people cannot be
// invited into the last one.
'seats' => ['used' => $team->memberships()->count() + count($invitations), 'limit' => $team->seat_limit],
'filters' => $filters,
]);
}
public function update(UpdateMemberRoles $request)
{
$team = $request->user()->currentTeam;
foreach ($request->validated('roles') as $id => $role) {
// Never the owner's: their row posts no select, and this keeps
// a forged one out too.
$team->memberships()->whereKey($id)->where('role', '!=', 'owner')->update(['role' => $role]);
}
return back()->with('status', 'Roles saved.');
}
public function destroy(Request $request, Membership $member)
{
abort_unless($member->team_id === $request->user()->currentTeam->id, 404);
abort_if($member->role === 'owner', 403, 'The owner cannot be removed.');
$request->user()->can('remove', $member) || abort(403);
$member->delete();
return back()->with('status', $member->user->name.' was removed.');
}
}
The roles' Form Request, so a role that is not offered cannot be posted:
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class UpdateMemberRoles extends FormRequest
{
public function authorize(): bool
{
return $this->user()->can('changeRoles', $this->user()->currentTeam);
}
public function rules(): array
{
return [
'roles' => ['required', 'array'],
'roles.*' => [Rule::in(['admin', 'editor', 'viewer'])],
];
}
}
Inviting
The tag input posts emails[], one per chip, and the role. Its own bag,
invite, keeps the message off the rest of the page:
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Validator;
class InvitePeople extends FormRequest
{
protected $errorBag = 'invite';
public function authorize(): bool
{
return $this->user()->can('invite', $this->user()->currentTeam);
}
public function rules(): array
{
$team = $this->user()->currentTeam;
return [
'emails' => ['required', 'array', 'max:'.$team->seatsLeft()],
'emails.*' => ['email:rfc', 'distinct', Rule::unique('invitations', 'email')->where('team_id', $team->id)],
'role' => ['required', Rule::in(['admin', 'editor', 'viewer'])],
];
}
public function messages(): array
{
return [
'emails.required' => 'Add at least one email address.',
'emails.max' => 'There are only :max seats left.',
'emails.*.email' => ':input is not an email address.',
'emails.*.unique' => ':input has already been invited.',
];
}
// The field shows one message, `emails`: move each address's onto it.
public function after(): array
{
return [function (Validator $validator) {
foreach ($validator->errors()->getMessages() as $key => $messages) {
if (str_starts_with($key, 'emails.')) {
$validator->errors()->add('emails', $messages[0]);
}
}
}];
}
}
namespace App\Http\Controllers;
use App\Http\Requests\InvitePeople;
use App\Mail\InvitationMail;
use App\Models\Invitation;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
class InvitationController
{
public function store(InvitePeople $request)
{
$team = $request->user()->currentTeam;
foreach ($request->validated('emails') as $email) {
$invitation = $team->invitations()->create([
'email' => $email,
'role' => $request->validated('role'),
'expires_at' => now()->addDays(7),
]);
Mail::to($email)->queue(new InvitationMail($invitation));
}
return back()->with('status', 'Invitations sent.');
}
public function resend(Request $request, Invitation $invitation)
{
$invitation->update(['expires_at' => now()->addDays(7)]);
Mail::to($invitation->email)->queue(new InvitationMail($invitation));
return back()->with('status', 'Sent again to '.$invitation->email.'.');
}
public function destroy(Request $request, Invitation $invitation)
{
$invitation->delete();
return back()->with('status', 'Invitation revoked.');
}
}
The after hook moves the per-address messages, which Laravel keys
emails.0, emails.1, onto emails, the one key the field reads. Check
in resend and destroy that the invitation is the current team's, as
destroy does for a member above.
Live, with Livewire
As a Livewire component, the roles bind to an array and the save bar is
told when it is dirty. ds::select passes no attributes on to its
<select>, so the role select is ds::input as="select", which does:
namespace App\Livewire;
use Livewire\Component;
use Livewire\WithPagination;
class Members extends Component
{
use WithPagination;
public array $roles = [];
public function mount(): void
{
$this->roles = auth()->user()->currentTeam->memberships()
->where('role', '!=', 'owner')->pluck('role', 'id')->all();
}
public function save(): void
{
$this->validate(['roles.*' => ['in:admin,editor,viewer']]);
foreach ($this->roles as $id => $role) {
auth()->user()->currentTeam->memberships()->whereKey($id)->where('role', '!=', 'owner')->update(['role' => $role]);
}
}
public function render()
{
return view('livewire.members', ['members' => auth()->user()->currentTeam->memberships()->with('user')->paginate(10)]);
}
}
<form wire:submit="save">
<x-ds::table label="Members" :columns="['Member', 'Role']">
@foreach ($members as $member)
<x-ds::table-row wire:key="member-{{ $member->id }}">
<x-ds::table-cell>{{ $member->user->name }}</x-ds::table-cell>
<x-ds::table-cell>
<x-ds::input as="select" :aria-label="'Role for '.$member->user->name" wire:model="roles.{{ $member->id }}">
<option value="admin">Admin</option>
<option value="editor">Editor</option>
<option value="viewer">Viewer</option>
</x-ds::input>
</x-ds::table-cell>
</x-ds::table-row>
@endforeach
</x-ds::table>
<x-ds::save-bar :dirty="false" wire:dirty.attr="data-ds-dirty" wire:target="roles"
x-on:discard="$wire.$refresh()" message="Role changes not saved yet" saveLabel="Save roles" />
</form>
Phone, keyboard, no script
- Phone: the invite form stacks, field over field over button; the filter bar wraps; the members table keeps its columns and scrolls sideways inside its border, with each role select wide enough to read. The settings nav is tabs above the page.
- Keyboard: Enter or comma adds an address in the tag input and Backspace in an empty field takes the last one off. Each role select is a Tab stop named "Role for" the member. Each row's menu opens from its "Actions for" button with Enter, Space or the arrow keys; the disabled Remove on the owner's row is skipped by the arrows, which is why the reason is in the row rather than on the item. The remove dialog takes focus, keeps it, and gives it back to the menu button on Cancel.
- No script: the filter bar is a GET form with an Apply button, the
role selects post with a plain Save roles at the foot of the table,
Resend posts, and the pages are links. Four things need Alpine: the tag
input (its text box posts nothing until the script turns what was typed
into a chip), Revoke (a confirm button fails safe, unreachable without
its script), each row's menu, and the remove dialog. A page that must work with none uses a plain
ds::input type="email"to invite one person at a time, and links each row's name to the member's own page, with a Remove form of its own.
From the package repo: edit this page on GitHub.