269 lines
14 KiB
PHP
269 lines
14 KiB
PHP
@extends('layouts.app')
|
|||
|
|
|
||
|
|
@section('content')
|
||
|
|
<div class="bg-gray-50 dark:bg-gray-900 min-h-screen">
|
||
|
|
<div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
||
|
|
<!-- Header -->
|
||
|
|
<div class="mb-8">
|
||
|
|
<div class="flex items-center justify-between">
|
||
|
|
<div>
|
||
|
|
<h1 class="text-3xl font-bold text-gray-900 dark:text-white">Edit User</h1>
|
||
|
|
<p class="mt-2 text-sm text-gray-600 dark:text-gray-400">Update user information and roles</p>
|
||
|
|
</div>
|
||
|
|
<a
|
||
|
|
href="{{ route('admin.users.index') }}"
|
||
|
|
class="px-4 py-2 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-md font-medium transition-colors"
|
||
|
|
>
|
||
|
|
Back to Users
|
||
|
|
</a>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Form -->
|
||
|
|
<form action="{{ route('admin.users.update', $user) }}" method="POST" class="space-y-6">
|
||
|
|
@csrf
|
||
|
|
@method('PUT')
|
||
|
|
|
||
|
|
<!-- User Avatar Display -->
|
||
|
|
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 p-6">
|
||
|
|
<div class="flex items-center">
|
||
|
|
@if($user->avatar_url)
|
||
|
|
<img class="h-20 w-20 rounded-full object-cover" src="{{ $user->avatar_url }}" alt="{{ $user->name }}">
|
||
|
|
@else
|
||
|
|
<div class="h-20 w-20 rounded-full bg-gradient-to-br from-primary-500 to-accent-500 flex items-center justify-center text-white text-2xl font-semibold">
|
||
|
|
{{ strtoupper(substr($user->name, 0, 1)) }}
|
||
|
|
</div>
|
||
|
|
@endif
|
||
|
|
<div class="ml-6">
|
||
|
|
<h3 class="text-lg font-medium text-gray-900 dark:text-white">{{ $user->name }}</h3>
|
||
|
|
<p class="text-sm text-gray-500 dark:text-gray-400">Editing user profile</p>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Basic Information -->
|
||
|
|
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 p-6">
|
||
|
|
<h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-4">Basic Information</h3>
|
||
|
|
|
||
|
|
<div class="space-y-4">
|
||
|
|
<!-- Name -->
|
||
|
|
<div>
|
||
|
|
<label for="name" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
|
||
|
|
Name <span class="text-red-500">*</span>
|
||
|
|
</label>
|
||
|
|
<input
|
||
|
|
type="text"
|
||
|
|
name="name"
|
||
|
|
id="name"
|
||
|
|
value="{{ old('name', $user->name) }}"
|
||
|
|
required
|
||
|
|
class="w-full rounded-md border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm focus:border-primary-500 focus:ring-primary-500 @error('name') border-red-500 @enderror"
|
||
|
|
>
|
||
|
|
@error('name')
|
||
|
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||
|
|
@enderror
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Email -->
|
||
|
|
<div>
|
||
|
|
<label for="email" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
|
||
|
|
Email <span class="text-red-500">*</span>
|
||
|
|
</label>
|
||
|
|
<input
|
||
|
|
type="email"
|
||
|
|
name="email"
|
||
|
|
id="email"
|
||
|
|
value="{{ old('email', $user->email) }}"
|
||
|
|
required
|
||
|
|
class="w-full rounded-md border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm focus:border-primary-500 focus:ring-primary-500 @error('email') border-red-500 @enderror"
|
||
|
|
>
|
||
|
|
@error('email')
|
||
|
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||
|
|
@enderror
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Bio -->
|
||
|
|
<div>
|
||
|
|
<label for="bio" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
|
||
|
|
Bio
|
||
|
|
</label>
|
||
|
|
<textarea
|
||
|
|
name="bio"
|
||
|
|
id="bio"
|
||
|
|
rows="3"
|
||
|
|
class="w-full rounded-md border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm focus:border-primary-500 focus:ring-primary-500 @error('bio') border-red-500 @enderror"
|
||
|
|
>{{ old('bio', $user->bio) }}</textarea>
|
||
|
|
@error('bio')
|
||
|
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||
|
|
@enderror
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Social Links -->
|
||
|
|
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 p-6">
|
||
|
|
<h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-4">Social Links</h3>
|
||
|
|
|
||
|
|
<div class="space-y-4">
|
||
|
|
<!-- Website -->
|
||
|
|
<div>
|
||
|
|
<label for="website" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
|
||
|
|
Website
|
||
|
|
</label>
|
||
|
|
<input
|
||
|
|
type="url"
|
||
|
|
name="website"
|
||
|
|
id="website"
|
||
|
|
value="{{ old('website', $user->website) }}"
|
||
|
|
placeholder="https://example.com"
|
||
|
|
class="w-full rounded-md border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm focus:border-primary-500 focus:ring-primary-500 @error('website') border-red-500 @enderror"
|
||
|
|
>
|
||
|
|
@error('website')
|
||
|
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||
|
|
@enderror
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Twitter -->
|
||
|
|
<div>
|
||
|
|
<label for="twitter" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
|
||
|
|
Twitter
|
||
|
|
</label>
|
||
|
|
<input
|
||
|
|
type="text"
|
||
|
|
name="twitter"
|
||
|
|
id="twitter"
|
||
|
|
value="{{ old('twitter', $user->twitter) }}"
|
||
|
|
placeholder="@username"
|
||
|
|
class="w-full rounded-md border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm focus:border-primary-500 focus:ring-primary-500 @error('twitter') border-red-500 @enderror"
|
||
|
|
>
|
||
|
|
@error('twitter')
|
||
|
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||
|
|
@enderror
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- GitHub -->
|
||
|
|
<div>
|
||
|
|
<label for="github" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
|
||
|
|
GitHub
|
||
|
|
</label>
|
||
|
|
<input
|
||
|
|
type="text"
|
||
|
|
name="github"
|
||
|
|
id="github"
|
||
|
|
value="{{ old('github', $user->github) }}"
|
||
|
|
placeholder="username"
|
||
|
|
class="w-full rounded-md border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm focus:border-primary-500 focus:ring-primary-500 @error('github') border-red-500 @enderror"
|
||
|
|
>
|
||
|
|
@error('github')
|
||
|
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||
|
|
@enderror
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- LinkedIn -->
|
||
|
|
<div>
|
||
|
|
<label for="linkedin" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
|
||
|
|
LinkedIn
|
||
|
|
</label>
|
||
|
|
<input
|
||
|
|
type="text"
|
||
|
|
name="linkedin"
|
||
|
|
id="linkedin"
|
||
|
|
value="{{ old('linkedin', $user->linkedin) }}"
|
||
|
|
placeholder="username"
|
||
|
|
class="w-full rounded-md border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm focus:border-primary-500 focus:ring-primary-500 @error('linkedin') border-red-500 @enderror"
|
||
|
|
>
|
||
|
|
@error('linkedin')
|
||
|
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||
|
|
@enderror
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Password -->
|
||
|
|
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 p-6">
|
||
|
|
<h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-4">Change Password</h3>
|
||
|
|
<p class="text-sm text-gray-600 dark:text-gray-400 mb-4">Leave blank to keep current password</p>
|
||
|
|
|
||
|
|
<div class="space-y-4">
|
||
|
|
<!-- New Password -->
|
||
|
|
<div>
|
||
|
|
<label for="password" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
|
||
|
|
New Password
|
||
|
|
</label>
|
||
|
|
<input
|
||
|
|
type="password"
|
||
|
|
name="password"
|
||
|
|
id="password"
|
||
|
|
class="w-full rounded-md border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm focus:border-primary-500 focus:ring-primary-500 @error('password') border-red-500 @enderror"
|
||
|
|
>
|
||
|
|
@error('password')
|
||
|
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||
|
|
@enderror
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Confirm Password -->
|
||
|
|
<div>
|
||
|
|
<label for="password_confirmation" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
|
||
|
|
Confirm New Password
|
||
|
|
</label>
|
||
|
|
<input
|
||
|
|
type="password"
|
||
|
|
name="password_confirmation"
|
||
|
|
id="password_confirmation"
|
||
|
|
class="w-full rounded-md border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm focus:border-primary-500 focus:ring-primary-500"
|
||
|
|
>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Roles -->
|
||
|
|
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 p-6">
|
||
|
|
<h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-4">
|
||
|
|
Roles <span class="text-red-500">*</span>
|
||
|
|
</h3>
|
||
|
|
<p class="text-sm text-gray-600 dark:text-gray-400 mb-4">Select at least one role for this user</p>
|
||
|
|
|
||
|
|
<div class="space-y-3">
|
||
|
|
@foreach($roles as $role)
|
||
|
|
<label class="flex items-start">
|
||
|
|
<input
|
||
|
|
type="checkbox"
|
||
|
|
name="roles[]"
|
||
|
|
value="{{ $role->id }}"
|
||
|
|
{{ in_array($role->id, old('roles', $user->roles->pluck('id')->toArray())) ? 'checked' : '' }}
|
||
|
|
class="mt-1 rounded border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500"
|
||
|
|
>
|
||
|
|
<div class="ml-3">
|
||
|
|
<span class="block text-sm font-medium text-gray-900 dark:text-white">{{ $role->name }}</span>
|
||
|
|
@if($role->description)
|
||
|
|
<span class="block text-sm text-gray-500 dark:text-gray-400">{{ $role->description }}</span>
|
||
|
|
@endif
|
||
|
|
</div>
|
||
|
|
</label>
|
||
|
|
@endforeach
|
||
|
|
</div>
|
||
|
|
@error('roles')
|
||
|
|
<p class="mt-2 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||
|
|
@enderror
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Actions -->
|
||
|
|
<div class="flex items-center justify-between">
|
||
|
|
<a
|
||
|
|
href="{{ route('admin.users.index') }}"
|
||
|
|
class="px-4 py-2 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-md font-medium transition-colors"
|
||
|
|
>
|
||
|
|
Cancel
|
||
|
|
</a>
|
||
|
|
<button
|
||
|
|
type="submit"
|
||
|
|
class="px-6 py-2 bg-primary-600 hover:bg-primary-700 text-white rounded-md font-medium transition-colors"
|
||
|
|
>
|
||
|
|
Update User
|
||
|
|
</button>
|
||
|
|
</div>
|
||
|
|
</form>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
@endsection
|