resetPage(); } /** * Get the users whose lifetime access status can be toggled, eager-loading * their current organization so we can show and flip its lifetime access * flag without extra queries. * * @return LengthAwarePaginator */ #[Computed] public function users(): LengthAwarePaginator { return $this->filteredUserQuery() ->with('currentOrganization') ->orderBy('name') ->paginate(self::PER_PAGE); } /** * @return Builder */ private function filteredUserQuery(): Builder { return User::query() ->when( $this->search !== '', fn (Builder $query) => $query->where(fn (Builder $query) => $query ->where('name', 'like', '%'.$this->search.'%') ->orWhere('email', 'like', '%'.$this->search.'%')) ); } /** * Flip the lifetime access flag on the given user's current organization. * Every user has a personal organization, so this is the organization that * controls whether they can use the app without a subscription. */ public function toggleLifetimeAccess(int $userId): void { Gate::authorize('accessAdmin'); $user = User::query()->findOrFail($userId); $organization = $user->currentOrganization; if ($organization === null) { Flux::toast(variant: 'danger', text: __('This user has no organization.')); return; } $organization->update(['lifetime_access' => ! $organization->lifetime_access]); Flux::toast( variant: 'success', text: $organization->lifetime_access ? __('Lifetime access enabled for :name.', ['name' => $user->name]) : __('Lifetime access disabled for :name.', ['name' => $user->name]), ); } }; ?>
{{ __('Lifetime access') }} {{ __('Grant or revoke perpetual access so users can use the app without a subscription.') }}
{{ __('Name') }} {{ __('Email') }} {{ __('Lifetime access') }} {{ __('Actions') }} @forelse ($this->users as $user) currentOrganization; $hasLifetime = $organization?->lifetime_access === true; ?> {{ $user->name }} {{ $user->email }} @if ($hasLifetime) {{ __('Lifetime') }} @else {{ __('None') }} @endif @empty {{ __('No users match your search.') }} @endforelse