edit user functionality

This commit is contained in:
2026-05-11 11:54:18 +08:00
parent 27c2869109
commit f110790e09
6 changed files with 166 additions and 1 deletions

View File

@@ -0,0 +1,46 @@
<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 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

@@ -17,6 +17,7 @@
<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">
@@ -26,10 +27,15 @@
<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="4" class="px-4 py-6 text-sm text-center text-gray-500">
<td colspan="5" class="px-4 py-6 text-sm text-center text-gray-500">
No users found.
</td>
</tr>