Add admin user management and improve UX

Features:
- Add user management for admins (CRUD operations)
- Add is_admin column to users table
- Add AdminMiddleware for authorization
- Add admin routes and views
- Add artisan command: user:set-admin

Improvements:
- Fix Quick Switcher: add x-data for Alpine.js dispatch
- Fix Quick Switcher: close on outside click
- Redirect non-admin users to front page after login
- Add Knowledge Base link in dashboard navigation
- Change app logo from Laravel to book icon
This commit is contained in:
2025-11-29 11:08:17 +09:00
parent 6e7f8566ef
commit c11c05b3ea
15 changed files with 543 additions and 12 deletions

View File

@@ -44,7 +44,8 @@
<button
type="button"
class="inline-flex items-center px-3 py-2 border border-gray-300 shadow-sm text-sm leading-4 font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
@click.prevent="console.log('Button clicked'); $dispatch('open-quick-switcher')"
x-data
@click.prevent="$dispatch('open-quick-switcher')"
>
<svg class="h-4 w-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path>
@@ -76,6 +77,16 @@ class="absolute right-0 mt-2 w-48 bg-white rounded-md shadow-lg py-1 ring-1 ring
<a href="{{ route('profile.edit') }}" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">
Profile
</a>
@if(Auth::user()->isAdmin())
<a href="{{ route('admin.users.index') }}" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">
<span class="flex items-center">
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z"></path>
</svg>
ユーザー管理
</span>
</a>
@endif
<form method="POST" action="{{ route('logout') }}">
@csrf
<button type="submit" class="w-full text-left block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">

View File

@@ -15,6 +15,12 @@
<x-nav-link :href="route('dashboard')" :active="request()->routeIs('dashboard')">
{{ __('Dashboard') }}
</x-nav-link>
<x-nav-link href="/" :active="false">
<svg class="w-4 h-4 mr-1 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 016 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25"></path>
</svg>
{{ __('Knowledge Base') }}
</x-nav-link>
</div>
</div>
@@ -38,6 +44,12 @@
{{ __('Profile') }}
</x-dropdown-link>
@if(Auth::user()->isAdmin())
<x-dropdown-link :href="route('admin.users.index')">
{{ __('ユーザー管理') }}
</x-dropdown-link>
@endif
<!-- Authentication -->
<form method="POST" action="{{ route('logout') }}">
@csrf
@@ -70,6 +82,9 @@
<x-responsive-nav-link :href="route('dashboard')" :active="request()->routeIs('dashboard')">
{{ __('Dashboard') }}
</x-responsive-nav-link>
<x-responsive-nav-link href="/" :active="false">
{{ __('Knowledge Base') }}
</x-responsive-nav-link>
</div>
<!-- Responsive Settings Options -->
@@ -84,6 +99,12 @@
{{ __('Profile') }}
</x-responsive-nav-link>
@if(Auth::user()->isAdmin())
<x-responsive-nav-link :href="route('admin.users.index')">
{{ __('ユーザー管理') }}
</x-responsive-nav-link>
@endif
<!-- Authentication -->
<form method="POST" action="{{ route('logout') }}">
@csrf