Feat: searchable-select для организации в пользователях
✅ edit.blade.php — выбор организации через searchable-select ✅ create.blade.php — выбор организации через searchable-select ✅ Контроллер не передаёт $organizations Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
parent
f8fc503177
commit
2e1fdee017
|
|
@ -50,11 +50,10 @@ class UserController extends Controller
|
|||
public function create()
|
||||
{
|
||||
Gate::authorize('create', User::class);
|
||||
|
||||
$organizations = Organization::pluck('name', 'id');
|
||||
|
||||
$roles = Role::pluck('name', 'name');
|
||||
|
||||
return view('admin.users.create', compact('organizations', 'roles'));
|
||||
|
||||
return view('admin.users.create', compact('roles'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
|
|
@ -100,7 +99,6 @@ class UserController extends Controller
|
|||
Gate::authorize('update', $user);
|
||||
|
||||
$user->load('groups');
|
||||
$organizations = Organization::pluck('name', 'id');
|
||||
$roles = Role::pluck('name', 'name');
|
||||
$userGroups = $user->groups->pluck('id')->toArray();
|
||||
|
||||
|
|
@ -113,7 +111,7 @@ class UserController extends Controller
|
|||
$allGroups = Group::whereNull('organization_id')->get();
|
||||
}
|
||||
|
||||
return view('admin.users.edit', compact('user', 'organizations', 'roles', 'userGroups', 'allGroups'));
|
||||
return view('admin.users.edit', compact('user', 'roles', 'userGroups', 'allGroups'));
|
||||
}
|
||||
|
||||
public function update(Request $request, User $user)
|
||||
|
|
|
|||
|
|
@ -46,12 +46,12 @@
|
|||
<h5>Настройки</h5>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Организация</label>
|
||||
<select name="organization_id" class="form-select">
|
||||
<option value="">Без организации</option>
|
||||
@foreach($organizations as $id => $name)
|
||||
<option value="{{ $id }}" {{ old('organization_id') == $id ? 'selected' : '' }}>{{ $name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<x-searchable-select
|
||||
name="organization_id"
|
||||
url="{{ route('api.organizations.search') }}"
|
||||
placeholder="Начните вводить название организации..."
|
||||
:value="old('organization_id')"
|
||||
/>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Роль *</label>
|
||||
|
|
|
|||
|
|
@ -45,12 +45,12 @@
|
|||
<h5>Настройки</h5>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Организация</label>
|
||||
<select name="organization_id" class="form-select">
|
||||
<option value="">Без организации</option>
|
||||
@foreach($organizations as $id => $name)
|
||||
<option value="{{ $id }}" {{ old('organization_id', $user->organization_id) == $id ? 'selected' : '' }}>{{ $name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<x-searchable-select
|
||||
name="organization_id"
|
||||
url="{{ route('api.organizations.search') }}"
|
||||
placeholder="Начните вводить название организации..."
|
||||
:value="old('organization_id', $user->organization_id)"
|
||||
/>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Роль *</label>
|
||||
|
|
|
|||
Loading…
Reference in New Issue