resetPage(); } #[Computed] public function users(): LengthAwarePaginator { return $this->filteredUserQuery() ->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.'%')) ); } public function startEditLimit(int $userId): void { $user = $this->userById($userId); $this->editingUserId = $user->id; $this->notesLimitInput = (string) $user->notesLimit(); $this->resetErrorBag('notesLimitInput'); $this->showLimitForm = true; } public function saveNotesLimit(): void { Gate::authorize('accessAdmin'); $user = $this->userById($this->editingUserId); $validated = $this->validate([ 'notesLimitInput' => ['required', 'integer', 'min:1', 'max:1000000'], ]); $user->update(['notes_limit' => (int) $validated['notesLimitInput']]); $this->reset('showLimitForm', 'editingUserId', 'notesLimitInput'); Flux::toast(variant: 'success', text: __('Notes limit updated.')); } private function userById(int $userId): User { return User::query()->findOrFail($userId); } }; ?>
{{ __('Notes limits') }} {{ __('Set how many characters each user may write in todo notes.') }}
@if ($search !== '') {{ __('Clear') }} @endif
{{ __('Name') }} {{ __('Email') }} {{ __('Site role') }} {{ __('Notes limit') }} {{ __('Actions') }} @forelse ($this->users as $user) {{ $user->name }} {{ $user->email }} @if ($user->isSiteAdmin()) {{ __('Site admin') }} @else {{ __('Member') }} @endif {{ $user->notesLimit() }} {{ __('characters') }}
@empty {{ __('No users match your search.') }} @endforelse
{{ __('Edit notes limit') }} {{ __('Enter the maximum number of characters allowed in todo notes.') }}
{{ __('Notes limit (characters)') }}
{{ __('Cancel') }} {{ __('Save') }}