@extends('Layouts.master')

@section('content')
    <div class="main-container pb-4" id="tables">
        @include('Partials.Pages.index_top')
        <div class="table-responsive">
            <table id="userTable" class="table table-hover table-striped">
                <thead>
                <tr>
                    <th scope="col">@lang('username')</th>
                    <th scope="col">@lang('name_full')</th>
                    <th scope="col">@lang('role')</th>
                    <th scope="col">@lang('action')</th>
                </tr>
                </thead>
                <tbody>
                @foreach($data as $user)
                    <tr>
                        <td scope="row">{{$user->username}}</td>
                        <td>{{$user->name}}</td>
                        <td>
                            @can('roles_view')
                                <a href="{{route('roles.show', ['role' => $user->role])}}"
                                   class="btn btn-success" target="_blank">
                                    {{$user->role->name}}
                                </a>
                            @else
                                {{$user->role->name}}
                            @endcan

                        </td>
                        <td>
                            @can('view',\App\Models\User::class)
                                <a href="{{route('users.show', ['user' => $user])}}"
                                   class="btn btn-success" target="_blank">
                                    @lang('show')
                                </a>
                            @endcan
                            @can('edit',\App\Models\User::class)
                                <a href="{{route('users.edit', ['user' => $user])}}"
                                   class="btn btn-outline-success">
                                    @lang('edit')
                                </a>
                            @endcan
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>
        @include('Partials.Pages.display')
    </div>
@endsection
@section('scripting')
@endsection