Skip to content
This repository was archived by the owner on Mar 12, 2024. It is now read-only.

Commit 9ef5748

Browse files
committed
assign multiple roles to user #2
1 parent 5ec06e6 commit 9ef5748

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

resources/views/user-ui/user.blade.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,23 @@
2828
<x-jet-input-error for="user.email" class="mt-2"/>
2929
</div>
3030
<div class="col-span-6 sm:col-span-4">
31-
<x-jet-label for="role" value="{{ __('Role') }}"/>
32-
<select wire:model="userRoles" multiple class='w-full border-gray-300 focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 rounded-md shadow-sm'>
33-
<option value="">{{ __('Choose') }}</option>
34-
@foreach($roles as $role)
35-
<option value="{{ $role->id }}">{{ $role->name }}</option>
36-
@endforeach
37-
</select>
31+
<x-jet-label for="role" value="{{ __('Role') }}"/>
32+
<div class="bg-white rounded-md -space-y-px">
33+
@foreach($roles as $role)
34+
<!-- Checked: "bg-indigo-50 border-indigo-200 z-10", Not Checked: "border-gray-200" -->
35+
<label class="@if(in_array($role->id,$userRoles)) bg-indigo-50 border-indigo-200 z-10 @else border-gray-200 @endif @if($loop->first) rounded-tl-md rounded-tr-md @endif @if($loop->last) rounded-bl-md rounded-br-md @endif relative border p-4 flex cursor-pointer">
36+
<input type="checkbox" value="{{ $role->id }}" wire:model="userRoles" class="invisible" aria-labelledby="privacy-setting-{{ $loop->iteration }}-label" aria-describedby="privacy-setting-{{ $loop->iteration }}-description">
37+
<div class="flex flex-col">
38+
<!-- Checked: "text-indigo-900", Not Checked: "text-gray-900" -->
39+
<span id="privacy-setting-{{ $loop->iteration }}-label" class="text-gray-900 block text-sm font-medium">{{ $role->name }}</span>
40+
<!-- Checked: "text-indigo-700", Not Checked: "text-gray-500" -->
41+
<span id="privacy-setting-{{ $loop->iteration }}-description" class="text-gray-500 block text-sm">{{ $role->description }}</span>
42+
</div>
43+
</label>
44+
@endforeach
45+
</div>
46+
47+
3848
<x-jet-input-error for="role" class="mt-2"/>
3949
</div>
4050
</x-slot>

src/LLoadoutInforceServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ private function publishAssets()
4545

4646
$this->publishes([
4747
__DIR__.'/../database/migrations/create_inforce_tables.php.stub' => base_path('database/migrations/'. date('Y_m_d_His').'_create_inforce_tables.php'),
48+
__DIR__.'/../database/migrations/update_roles_table.php.stub' => base_path('database/migrations/'. date('Y_m_d_His').'_update_roles_table.php'),
4849
], 'LLoadoutInforce-migrations');
4950

5051
return $this;

0 commit comments

Comments
 (0)