59 lines
2.5 KiB
PHP
59 lines
2.5 KiB
PHP
@extends('admin.layout')
|
|
|
|
@section('title', '用户管理')
|
|
@section('page-title', '用户管理')
|
|
|
|
@section('actions')
|
|
@canPerm('users.create')
|
|
<a href="{{ route('admin.users.create') }}" class="btn btn-primary"><x-icon name="plus" :size="16"/> 新建用户</a>
|
|
@endcanPerm
|
|
@endsection
|
|
|
|
@section('content')
|
|
<form method="GET" class="filter-bar">
|
|
<input type="text" name="q" value="{{ $q }}" class="input" placeholder="搜索姓名、邮箱...">
|
|
<button type="submit" class="btn btn-primary">查询</button>
|
|
</form>
|
|
|
|
<table class="data-table" style="margin-top:16px;">
|
|
<thead><tr><th>姓名</th><th>邮箱</th><th>角色</th><th>积分 / 等级</th><th class="col-op">操作</th></tr></thead>
|
|
<tbody>
|
|
@forelse ($users as $u)
|
|
@php
|
|
$me = auth()->user();
|
|
$canManage = $me->isSuperAdmin() || $me->roleLevel() > $u->roleLevel();
|
|
@endphp
|
|
<tr>
|
|
<td>{{ $u->name }}</td>
|
|
<td>{{ $u->email }}</td>
|
|
<td>
|
|
<span class="badge badge-role-{{ $u->role }}">{{ $u->roleLabel() }}</span>
|
|
@if ($u->id === $me->id)<span class="muted">(当前)</span>@endif
|
|
</td>
|
|
<td class="muted">{{ $u->points ?? 0 }} · L{{ $u->level() }}</td>
|
|
<td class="row-actions">
|
|
@if ($canManage)
|
|
@canPerm('users.assign_role')
|
|
<a href="{{ route('admin.users.edit', $u) }}" class="btn btn-sm"><x-icon name="edit" :size="16"/> 角色/权限</a>
|
|
@endcanPerm
|
|
@canPerm('users.reset_password')
|
|
<a href="{{ route('admin.users.edit', $u) }}#reset-password" class="btn btn-sm"><x-icon name="lock" :size="16"/> 重置密码</a>
|
|
@endcanPerm
|
|
@else
|
|
<span class="muted">无权操作</span>
|
|
@endif
|
|
@canPerm('users.delete')
|
|
@if ($canManage && $u->id !== $me->id)
|
|
<form method="POST" action="{{ route('admin.users.destroy', $u) }}" onsubmit="return confirm('确认删除该用户?')">@csrf @method('DELETE')<button class="btn btn-sm btn-danger"><x-icon name="trash" :size="16"/></button></form>
|
|
@endif
|
|
@endcanPerm
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr><td colspan="5" class="muted">暂无用户。</td></tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
{{ $users->links('pagination::bootstrap-5') }}
|
|
@endsection
|