Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix user creation is missing a role input if role is Administrator or lower #2550

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Http/Controllers/Admin/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,7 @@ protected function getIndexData(array $prependScope = []): array
// @todo: use $this->filters instead of indexData.
$indexDataWithoutFilters = $this->indexData($this->request);
foreach ($indexDataWithoutFilters as $key => $value) {
if (Str::endsWith($key, 'List')) {
if ($key !== 'roleList' && Str::endsWith($key, 'List')) {
unset($indexDataWithoutFilters[$key]);
}
}
Expand Down Expand Up @@ -1922,7 +1922,7 @@ public function filters(): TableFilters
$tableFilters = TableFilters::make();

foreach ($this->indexData($this->request) as $key => $value) {
if (Str::endsWith($key, 'List')) {
if ($key !== 'roleList' && Str::endsWith($key, 'List')) {
$queryString = Str::beforeLast($key, 'List');

if ($filterKey = ($this->filters[$queryString] ?? false)) {
Expand Down
20 changes: 9 additions & 11 deletions views/users/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@
type="email"
/>

@can('edit-user-roles')
Tofandel marked this conversation as resolved.
Show resolved Hide resolved
@php $userModel = twillModel('user') @endphp
@php $userModel = twillModel('user') @endphp

<x-twill::select
:name="$userModel::getRoleColumnName()"
:label="twillTrans('twill::lang.user-management.role')"
:native="true"
:options="$roleList ?? []"
:default="$roleList[0]['value'] ?? ''"
placeholder="Select a role"
/>
@endcan
<x-twill::select
:name="$userModel::getRoleColumnName()"
:label="twillTrans('twill::lang.user-management.role')"
:native="true"
:options="$roleList ?? []"
:default="$roleList[0]['value'] ?? ''"
placeholder="Select a role"
/>
@endunless
Loading