@extends('backend.layouts.master')
@section('section-title', 'User Management')
@section('page-title', 'User List')
@if (check_permission('user.create'))
    @section('action-button')
        <a class="btn btn-primary-rgba" href="{{ route('user.create') }}">
            <i class="mr-2 feather icon-plus"></i>
            Add User
        </a>
    @endsection
@endif
@section('content')
    <div class="row">
        <div class="col-lg-12">
            <div class="card m-b-30">
                <div class="card-header">
                    <h5 class="card-title">User List</h5>
                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table id="datatable-buttons" class="table table-striped table-bordered text-center">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Photo</th>
                                    <th>Name</th>
                                    <th>Email</th>
                                    <th>Phone</th>
                                    <th>User Role</th>
                                    <th>Status</th>
                                    <th>Actions</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach ($users as $user)
                                    <tr>
                                        <td>{{ $loop->index + 1 }}</td>
                                        <td>
                                            <img src="{{ (!empty($user->image))?url('public/uploads/users/'.$user->image):url('public/backend/images/users/profile.svg') }}" alt="{{ $user->name }}" style="height: 30px; width: 30px;">
                                        </td>
                                        <td>{{ $user->name }}</td>
                                        <td>{{ $user->email }}</td>
                                        <td>{{ ($user->phone!=NULL)?$user->phone:'--'; }}</td>
                                        <td>{{ $user->role->name }}</td>
                                        <td>
                                            <input type="checkbox" data-toggle="toggle" data-on="Active"
                                                class="status-update" {{ $user->status == 1 ? 'checked' : '' }}
                                                data-off="Inactive" data-onstyle="success" data-offstyle="danger"
                                                data-id="{{ $user->id }}" data-model="User">
                                        </td>
                                        <td>
                                            @if (check_permission('user.edit'))
                                                <a href="{{ route('user.edit', $user->id) }}"
                                                    class="btn btn-primary-rgba">
                                                    <i class="feather icon-edit"></i>
                                                </a>
                                            @endif
                                        </td>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
