LMS/resources/views/admin/users/index.blade.php

114 lines
5.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@extends('layouts.app')
@section('title', 'Пользователи')
@section('content')
<div class="container-fluid">
<div class="row">
<nav class="col-md-3 col-lg-2 d-md-block sidebar collapse">
<div class="position-sticky pt-3">
@include('partials._sidebar')
</div>
</nav>
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4 main-content">
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h1 class="h2">Пользователи</h1>
@can('create', App\Models\User::class)
<a href="{{ route('admin.users.create') }}" class="btn btn-primary btn-sm">
<i class="bi bi-plus-lg"></i> Добавить пользователя
</a>
@endcan
</div>
@if(session('success'))
<div class="alert alert-success">{{ session('success') }}</div>
@endif
<div class="card shadow-sm mb-4">
<div class="card-body">
<form action="{{ route('admin.users.index') }}" method="GET" class="row g-3">
<div class="col-md-3">
<input type="text" name="search" class="form-control" placeholder="Поиск..." value="{{ request('search') }}">
</div>
<div class="col-md-3">
<select name="organization_id" class="form-select">
<option value="">Все организации</option>
@foreach($organizations as $id => $name)
<option value="{{ $id }}" {{ request('organization_id') == $id ? 'selected' : '' }}>{{ $name }}</option>
@endforeach
</select>
</div>
<div class="col-md-3">
<select name="role" class="form-select">
<option value="">Все роли</option>
@foreach($roles as $role)
<option value="{{ $role }}" {{ request('role') == $role ? 'selected' : '' }}>{{ $role }}</option>
@endforeach
</select>
</div>
<div class="col-md-3">
<button type="submit" class="btn btn-primary"><i class="bi bi-search"></i></button>
<a href="{{ route('admin.users.index') }}" class="btn btn-secondary"><i class="bi bi-x-lg"></i></a>
</div>
</form>
</div>
</div>
<div class="card shadow-sm">
<div class="card-body">
<table class="table table-hover">
<thead>
<tr>
<th>ID</th>
<th>Имя</th>
<th>Email</th>
<th>Организация</th>
<th>Роль</th>
<th>Статус</th>
<th>Действия</th>
</tr>
</thead>
<tbody>
@forelse($users as $user)
<tr>
<td>{{ $user->id }}</td>
<td><a href="{{ route('admin.users.show', $user) }}">{{ $user->name }}</a></td>
<td>{{ $user->email }}</td>
<td>{{ $user->organization?->name ?? '—' }}</td>
<td><span class="badge bg-info">{{ $user->getRoleNames()->first() }}</span></td>
<td>
@if($user->is_active)
<span class="badge bg-success">Активен</span>
@else
<span class="badge bg-secondary">Не активен</span>
@endif
</td>
<td>
<div class="btn-group btn-group-sm">
<a href="{{ route('admin.users.show', $user) }}" class="btn btn-outline-primary"><i class="bi bi-eye"></i></a>
@can('update', $user)
<a href="{{ route('admin.users.edit', $user) }}" class="btn btn-outline-warning"><i class="bi bi-pencil"></i></a>
@endcan
@can('delete', $user)
<form action="{{ route('admin.users.destroy', $user) }}" method="POST" class="d-inline" onsubmit="return confirm('Удалить?')">
@csrf @method('DELETE')
<button class="btn btn-outline-danger"><i class="bi bi-trash"></i></button>
</form>
@endcan
</div>
</td>
</tr>
@empty
<tr><td colspan="7" class="text-center text-muted">Пользователей нет</td></tr>
@endforelse
</tbody>
</table>
</div>
</div>
{{ $users->links() }}
</main>
</div>
</div>
@endsection