Merge branch 'user-module'

This commit is contained in:
2026-05-11 12:39:30 +08:00
16 changed files with 607 additions and 0 deletions

View File

@@ -15,6 +15,12 @@
<x-nav-link :href="route('dashboard')" :active="request()->routeIs('dashboard')">
{{ __('Dashboard') }}
</x-nav-link>
<x-nav-link :href="route('user.index')" :active="request()->routeIs('user.index')">
{{ __('Users') }}
</x-nav-link>
<x-nav-link :href="route('role.index')" :active="request()->routeIs('role.index')">
{{ __('Roles') }}
</x-nav-link>
</div>
</div>
@@ -70,6 +76,12 @@
<x-responsive-nav-link :href="route('dashboard')" :active="request()->routeIs('dashboard')">
{{ __('Dashboard') }}
</x-responsive-nav-link>
<x-responsive-nav-link :href="route('user.index')" :active="request()->routeIs('user.index')">
{{ __('Users') }}
</x-responsive-nav-link>
<x-responsive-nav-link :href="route('role.index')" :active="request()->routeIs('role.index')">
{{ __('Roles') }}
</x-responsive-nav-link>
</div>
<!-- Responsive Settings Options -->

View File

@@ -0,0 +1,33 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('Create Role') }}
</h2>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 text-gray-900">
<form method="POST" action="{{ route('role.store') }}" class="space-y-6 max-w-xl">
@csrf
<div>
<x-input-label for="name" :value="__('Name')" />
<x-text-input id="name" class="mt-1 block w-full" type="text" name="name" :value="old('name')" required autofocus autocomplete="off" />
<x-input-error class="mt-2" :messages="$errors->get('name')" />
</div>
<div class="flex items-center gap-4">
<x-primary-button>{{ __('Save') }}</x-primary-button>
<a href="{{ route('role.index') }}" class="text-sm text-gray-600 underline hover:text-gray-900">
{{ __('Cancel') }}
</a>
</div>
</form>
</div>
</div>
</div>
</div>
</x-app-layout>

View File

@@ -0,0 +1,54 @@
<x-app-layout>
<x-slot name="header">
<div class="flex items-center justify-between gap-4">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('Roles') }}
</h2>
<a href="{{ route('role.create') }}" class="inline-flex items-center rounded-md border border-transparent bg-gray-800 px-4 py-2 text-xs font-semibold uppercase tracking-widest text-white transition hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2">
{{ __('New Role') }}
</a>
</div>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 text-gray-900">
@if (session('status') === 'role-created')
<div class="mb-4 rounded-md bg-green-50 px-4 py-3 text-sm text-green-700">
{{ __('Role created successfully.') }}
</div>
@endif
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th>
<th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
<th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Created</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
@forelse ($roles as $role)
<tr class="odd:bg-white even:bg-gray-50">
<td class="px-4 py-3 text-sm text-gray-700">{{ $role->id }}</td>
<td class="px-4 py-3 text-sm text-gray-900">{{ $role->name }}</td>
<td class="px-4 py-3 text-sm text-gray-700">{{ $role->created_at?->format('Y-m-d H:i') }}</td>
</tr>
@empty
<tr>
<td colspan="3" class="px-4 py-6 text-center text-sm text-gray-500">
No roles found.
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</x-app-layout>

View File

@@ -0,0 +1,70 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('Edit User') }}
</h2>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 text-gray-900">
@if (session('status') === 'user-updated')
<div class="mb-4 rounded-md bg-green-50 px-4 py-3 text-sm text-green-700">
{{ __('User updated successfully.') }}
</div>
@endif
<form method="POST" action="{{ route('user.update', $user) }}" class="space-y-6 max-w-xl">
@csrf
@method('patch')
<div>
<x-input-label for="name" :value="__('Name')" />
<x-text-input id="name" class="mt-1 block w-full" type="text" name="name" :value="old('name', $user->name)" required autofocus autocomplete="name" />
<x-input-error class="mt-2" :messages="$errors->get('name')" />
</div>
<div>
<x-input-label for="email" :value="__('Email')" />
<x-text-input id="email" class="mt-1 block w-full" type="email" name="email" :value="old('email', $user->email)" required autocomplete="username" />
<x-input-error class="mt-2" :messages="$errors->get('email')" />
</div>
<div>
<x-input-label :value="__('Roles')" />
<div class="mt-2 space-y-2 rounded-md border border-gray-200 p-4">
@forelse ($roles as $role)
<label class="flex items-center gap-2">
<input
type="checkbox"
name="roles[]"
value="{{ $role->id }}"
@checked(in_array($role->id, old('roles', $user->roles->pluck('id')->all()), true))
class="rounded border-gray-300 text-indigo-600 shadow-sm focus:ring-indigo-500"
>
<span class="text-sm text-gray-700">{{ $role->name }}</span>
</label>
@empty
<p class="text-sm text-gray-500">{{ __('No roles available.') }}</p>
@endforelse
</div>
<x-input-error class="mt-2" :messages="$errors->get('roles')" />
<x-input-error class="mt-2" :messages="$errors->get('roles.*')" />
</div>
<div class="flex items-center gap-4">
<x-primary-button>{{ __('Save') }}</x-primary-button>
<a href="{{ route('user.index') }}" class="text-sm text-gray-600 underline hover:text-gray-900">
{{ __('Back') }}
</a>
</div>
</form>
</div>
</div>
</div>
</div>
</x-app-layout>

View File

@@ -0,0 +1,54 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('Users') }}
</h2>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 text-gray-900">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th>
<th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
<th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th>
<th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Created</th>
<th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
@forelse ($users as $user)
<tr class="odd:bg-white even:bg-gray-50">
<td class="px-4 py-3 text-sm text-gray-700">{{ $user->id }}</td>
<td class="px-4 py-3 text-sm text-gray-900">{{ $user->name }}</td>
<td class="px-4 py-3 text-sm text-gray-700">{{ $user->email }}</td>
<td class="px-4 py-3 text-sm text-gray-700">{{ $user->created_at?->format('Y-m-d H:i') }}</td>
<td class="px-4 py-3 text-sm text-gray-700">
<a href="{{ route('user.edit', $user) }}" class="font-medium text-indigo-600 hover:text-indigo-500">
{{ __('Edit') }}
</a>
</td>
</tr>
@empty
<tr>
<td colspan="5" class="px-4 py-6 text-sm text-center text-gray-500">
No users found.
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div class="mt-6">
{{ $users->links() }}
</div>
</div>
</div>
</div>
</div>
</x-app-layout>