First Commit

This commit is contained in:
marco
2026-09-01 07:49:48 -03:00
commit 28b1044038
399 changed files with 41659 additions and 0 deletions
+154
View File
@@ -0,0 +1,154 @@
@extends("layouts.app")
@section("title", __("Edit User"))
@section("header")
<div class="flex justify-between items-center">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __("Edit User") }}
</h2>
</div>
@endsection
@section("content")
<div class="py-6">
<div class="max-w-3xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
<div class="flex items-center gap-4 mb-6">
<span class="w-16 h-16 rounded-full bg-indigo-100 flex items-center justify-center text-xl font-bold text-indigo-600">
{{ substr($user->name, 0, 1) }}
</span>
<div>
<h3 class="text-xl font-semibold text-gray-900">{{ $user->name }}</h3>
<p class="text-sm text-gray-500">{{ $user->email }}</p>
</div>
</div>
<form method="POST" action="{{ route("superadmin.users.update", $user) }}">
@csrf
@method("PUT")
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
<div>
<label for="name" class="block text-sm font-medium text-gray-700 mb-2">{{ __("Name") }}</label>
<input type="text" name="name" id="name" value="{{ old("name", $user->name) }}" required
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500">
</div>
<div>
<label for="email" class="block text-sm font-medium text-gray-700 mb-2">{{ __("Email") }}</label>
<input type="email" name="email" id="email" value="{{ old("email", $user->email) }}" required
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500">
</div>
</div>
<div class="mb-6">
<label for="role" class="block text-sm font-medium text-gray-700 mb-2">{{ __("Role") }}</label>
<select name="role" id="role" required
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500">
<option value="admin" {{ $user->hasRole('admin') ? 'selected' : '' }}>{{ __("Admin") }}</option>
<option value="superadmin" {{ $user->hasRole('superadmin') ? 'selected' : '' }}>{{ __("SuperAdmin") }}</option>
</select>
</div>
<div class="mb-6">
<label for="plan_id" class="block text-sm font-medium text-gray-700 mb-2">{{ __("Subscription Plan") }}</label>
<select name="plan_id" id="plan_id" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500">
<option value="">{{ __("No plan") }}</option>
@foreach(\App\Models\SubscriptionPlan::where('is_active', true)->get() as $plan)
@php $activeSub = $user->subscriptions()->where('status', 'active')->first(); @endphp
<option value="{{ $plan->id }}" {{ $activeSub && $activeSub->subscription_plan_id == $plan->id ? 'selected' : '' }}>
{{ $plan->name }} - R$ {{ number_format($plan->price, 2, ',', '.') }} / {{ $plan->duration_days }}d
({{ $plan->token_limit ? number_format($plan->token_limit) . ' tokens' : __('Unlimited') }})
</option>
@endforeach
</select>
@if($activeSub ?? false)
<p class="text-xs text-gray-500 mt-1">
{{ __("Current plan ends: :date", ['date' => $activeSub->end_date->format('d/m/Y')]) }}
</p>
@endif
</div>
<div class="mb-6">
<label for="token_limit" class="block text-sm font-medium text-gray-700 mb-2">{{ __("Token Limit") }}</label>
<p class="text-xs text-gray-500 mb-2">{{ __("Maximum tokens this user can consume. Leave empty for unlimited.") }}</p>
<input type="number" name="token_limit" id="token_limit"
value="{{ old("token_limit", $user->token_limit) }}" min="0" step="1000"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500"
placeholder="{{ __("e.g., 100000 for 100k tokens") }}">
@php
$totalUsed = \App\Models\TokenUsage::where('user_id', $user->id)->sum('total_tokens');
@endphp
@if($totalUsed > 0)
<p class="text-xs text-gray-500 mt-1">
{{ __("Current usage: :used tokens", ['used' => number_format($totalUsed)]) }}
@if($user->token_limit)
| {{ __("Limit: :limit tokens", ['limit' => number_format($user->token_limit)]) }}
| {{ round(($totalUsed / $user->token_limit) * 100) }}% {{ __("used") }}
@endif
</p>
@endif
</div>
<div class="mb-6">
<h3 class="text-lg font-semibold text-gray-900 mb-2">{{ __("Update Password") }}</h3>
<p class="text-xs text-gray-500 mb-4">{{ __("Leave blank to keep current password") }}</p>
<div class="mb-4">
<label for="password" class="block text-sm font-medium text-gray-700 mb-2">{{ __("New Password") }}</label>
<div class="relative">
<input type="password" name="password" id="password"
class="w-full px-3 py-2 pr-10 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500">
<button type="button" onclick="togglePassword('password', this)" class="absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/></svg>
</button>
</div>
@error('password')
<p class="text-red-500 text-sm mt-1">{{ $message }}</p>
@enderror
</div>
<div class="mb-4">
<label for="password_confirmation" class="block text-sm font-medium text-gray-700 mb-2">{{ __("Confirm New Password") }}</label>
<div class="relative">
<input type="password" name="password_confirmation" id="password_confirmation"
class="w-full px-3 py-2 pr-10 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500">
<button type="button" onclick="togglePassword('password_confirmation', this)" class="absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/></svg>
</button>
</div>
@error('password_confirmation')
<p class="text-red-500 text-sm mt-1">{{ $message }}</p>
@enderror
</div>
</div>
<div class="flex items-center justify-between pt-4 border-t border-gray-100">
<a href="{{ route("superadmin.users.index") }}"
class="px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition font-medium">
{{ __("Back") }}
</a>
<button type="submit" class="px-6 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition font-medium">
{{ __("Update User") }}
</button>
</div>
</form>
</div>
</div>
</div>
@endsection
@push('scripts')
<script>
function togglePassword(fieldId, btn) {
var input = document.getElementById(fieldId);
if (input.type === 'password') {
input.type = 'text';
btn.innerHTML = '<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"/></svg>';
} else {
input.type = 'password';
btn.innerHTML = '<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/></svg>';
}
}
</script>
@endpush
+203
View File
@@ -0,0 +1,203 @@
@extends("layouts.app")
@section("title", __("User Management"))
@section("header")
<div class="flex justify-between items-center">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __("User Management") }}
</h2>
</div>
@endsection
@section("content")
<div class="py-6">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
@if(session("success"))
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded-lg mb-6">
{{ session("success") }}
</div>
@endif
@if(session("info"))
<div class="bg-blue-100 border border-blue-400 text-blue-700 px-4 py-3 rounded-lg mb-6">
{{ session("info") }}
</div>
@endif
<!-- Stats Cards -->
<div class="grid grid-cols-1 md:grid-cols-5 gap-4 mb-6">
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-4">
<p class="text-xs font-medium text-gray-500">{{ __("Total") }}</p>
<p class="text-2xl font-bold text-gray-900">{{ $stats["total"] }}</p>
</div>
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-4">
<p class="text-xs font-medium text-gray-500">{{ __("Pending") }}</p>
<p class="text-2xl font-bold text-yellow-600">{{ $stats["pending"] }}</p>
</div>
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-4">
<p class="text-xs font-medium text-gray-500">{{ __("Active") }}</p>
<p class="text-2xl font-bold text-green-600">{{ $stats["active"] }}</p>
</div>
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-4">
<p class="text-xs font-medium text-gray-500">{{ __("Paused") }}</p>
<p class="text-2xl font-bold text-red-600">{{ $stats["paused"] }}</p>
</div>
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-4">
<p class="text-xs font-medium text-gray-500">{{ __("Unverified") }}</p>
<p class="text-2xl font-bold text-orange-600">{{ $stats["unverified"] }}</p>
</div>
</div>
<!-- Filters -->
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-4 mb-6">
<form method="GET" class="flex flex-wrap gap-3 items-center">
<div class="flex-1 min-w-[200px]">
<input type="text" name="search" value="{{ request('search') }}"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 text-sm"
placeholder="{{ __("Search by name or email...") }}">
</div>
<select name="status" class="px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 text-sm">
<option value="">{{ __("All Status") }}</option>
<option value="pending" {{ request('status') == 'pending' ? 'selected' : '' }}>{{ __("Pending") }}</option>
<option value="approved" {{ request('status') == 'approved' ? 'selected' : '' }}>{{ __("Approved") }}</option>
<option value="paused" {{ request('status') == 'paused' ? 'selected' : '' }}>{{ __("Paused") }}</option>
<option value="verified" {{ request('status') == 'verified' ? 'selected' : '' }}>{{ __("Verified") }}</option>
<option value="unverified" {{ request('status') == 'unverified' ? 'selected' : '' }}>{{ __("Unverified") }}</option>
</select>
<button type="submit" class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition text-sm font-medium">
{{ __("Filter") }}
</button>
@if(request('search') || request('status'))
<a href="{{ route("superadmin.users.index") }}" class="px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition text-sm font-medium">
{{ __("Clear") }}
</a>
@endif
</form>
</div>
<!-- Users Table -->
<div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ __("User") }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ __("Role") }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ __("Status") }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ __("Email Verified") }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ __("Joined") }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ __("Actions") }}</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
@forelse($users as $user)
<tr class="hover:bg-gray-50">
<td class="px-6 py-4 whitespace-nowrap">
<div class="flex items-center">
<span class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center text-xs font-bold text-indigo-600 mr-3">
{{ substr($user->name, 0, 1) }}
</span>
<div>
<p class="text-sm font-medium text-gray-900">{{ $user->name }}</p>
<p class="text-xs text-gray-500">{{ $user->email }}</p>
</div>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full {{ $user->hasRole('superadmin') ? 'bg-purple-100 text-purple-800' : 'bg-indigo-100 text-indigo-800' }}">
{{ $user->getRoleNames()->first() ?? __('admin') }}
</span>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="flex flex-col gap-1">
@if($user->is_approved && $user->is_active)
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">
{{ __("Active") }}
</span>
@elseif(!$user->is_approved)
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-yellow-100 text-yellow-800">
{{ __("Pending") }}
</span>
@elseif(!$user->is_active)
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">
{{ __("Paused") }}
</span>
@endif
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
@if($user->hasVerifiedEmail())
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">
{{ __("Verified") }}
</span>
@else
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-orange-100 text-orange-800">
{{ __("Unverified") }}
</span>
@endif
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $user->created_at->format('d/m/Y') }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm">
<div class="flex flex-col gap-1">
<div class="flex gap-1 flex-wrap">
@if(!$user->is_approved)
<form action="{{ route("superadmin.users.approve", $user) }}" method="POST" class="inline">
@csrf
<button type="submit" class="px-2 py-1 bg-green-600 text-white text-xs rounded hover:bg-green-700">
{{ __("Approve") }}
</button>
</form>
@endif
@if(!$user->hasVerifiedEmail())
<form action="{{ route("superadmin.users.verify-email", $user) }}" method="POST" class="inline">
@csrf
<button type="submit" class="px-2 py-1 bg-blue-600 text-white text-xs rounded hover:bg-blue-700">
{{ __("Verify Email") }}
</button>
</form>
@endif
<form action="{{ route("superadmin.users.toggle-active", $user) }}" method="POST" class="inline">
@csrf
<button type="submit" class="px-2 py-1 {{ $user->is_active ? 'bg-red-600 hover:bg-red-700' : 'bg-green-600 hover:bg-green-700' }} text-white text-xs rounded">
{{ $user->is_active ? __("Pause") : __("Activate") }}
</button>
</form>
<a href="{{ route("superadmin.users.edit", $user) }}"
class="px-2 py-1 bg-indigo-600 text-white text-xs rounded hover:bg-indigo-700 inline-block">
{{ __("Edit") }}
</a>
<form action="{{ route("superadmin.users.destroy", $user) }}" method="POST" class="inline"
onsubmit="return confirm('{{ __("Delete this user? All associated data will be permanently removed.") }}')">
@csrf
@method("DELETE")
<button type="submit" class="px-2 py-1 bg-red-600 text-white text-xs rounded hover:bg-red-700">
{{ __("Delete") }}
</button>
</form>
</div>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="6" class="px-6 py-12 text-center text-gray-500">
{{ __("No users found.") }}
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
@if(method_exists($users, 'links'))
<div class="p-4 border-t border-gray-100">
{{ $users->links() }}
</div>
@endif
</div>
</div>
</div>
@endsection