@extends('superadmin.layout')
@section('content')

    <!-- begin::main content -->
    <main class="main-content">
        <div class="container">

            <!-- begin::page header -->
            <div class="page-header">
                <h3>Edit User</h3>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="#">Dashboard</a></li>
                        <li class="breadcrumb-item"><a href="{{ asset('users') }}">users</a></li>
                        <li class="breadcrumb-item active" aria-current="page">Edit User</li>
                    </ol>
                </nav>
            </div>
            <!-- end::page header -->
            <x-flashMessage />
            <div class="row">
                <div class="col-md-6">

                    <div class="card">
                        <div class="card-header">
                            <a href="{{ asset('users') }}" class="btn btn-primary pull-right  text-white"><i
                                    class="fa fa-list"></i>&nbsp;User List</a>
                        </div>
                        <div class="card-body">
                            <form action="{{ asset('edit-user/'.$user->id) }}" method="post">
                                @csrf
                                <div class="form-group">
                                    <label for="username">User Name</label>
                                    <input type="text" class="form-control" name="username" value="{{ $user->name }}"
                                        id="username" placeholder="Enter User Name">

                                    @if ($errors->has('username'))
                                        <div class="error">
                                            {{ $errors->first('username') }}
                                        </div>
                                    @endif

                                </div>

                                <div class="form-group">
                                    <label for="email">Email</label>
                                    <input type="email" class="form-control" name="email"
                                        value="{{ !empty($user->email) ? $user->email : '' }}" id="email"
                                        placeholder="Enter Email Name">

                                    @if ($errors->has('email'))
                                        <div class="error">
                                            {{ $errors->first('email') }}
                                        </div>
                                    @endif

                                </div>

                                <div class="form-group">
                                    <label for="phone">Mobile (Optional)</label>
                                    <input type="number" class="form-control" name="phone"
                                        value="{{ !empty($user->phone) ? $user->phone : '' }}" id="phone"
                                        placeholder="Enter Phone">

                                    @if ($errors->has('phone'))
                                        <div class="error">
                                            {{ $errors->first('phone') }}
                                        </div>
                                    @endif

                                </div>


                                <div class="form-group">
                                    <label for="dob">DOB (Optional)</label>
                                    <input type="date" class="form-control" name="dob"
                                        value="{{ !empty($user->dob) ? $user->dob : '' }}" id="dob"
                                        placeholder="Date of birth">
                                </div>



                                <div class="form-group">

                                    <label for="institute">Role</label>
                                    <select multiple id="js-example-basic-roles" name="role[]">
                                        <option></option>
                                        @if (!empty($roles))
                                            @foreach ($roles as $role)
                                                <option value="{{ $role->slug }}">{{ $role->name }}</option>
                                            @endforeach
                                        @endif
                                    </select>

                                    @if ($errors->has('role'))
                                        <div class="error">
                                            {{ $errors->first('role') }}
                                        </div>
                                    @endif
                                </div>
                                <button type="submit" class="btn btn-primary">Submit</button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </main>
    <!-- end::main content -->

@endsection
@push('footer-script')
    <!-- begin::select2 -->
    <link rel="stylesheet" href="{{ asset('public/admin/vendors/select2/css/select2.min.css') }}" type="text/css">
    <!-- end::select2 -->

    <script src="{{ asset('public/admin/vendors/select2/js/select2.min.js') }}"></script>
    <script src="{{ asset('public/admin/js/examples/select2.js') }}"></script>
    <!-- end::select2 -->

    <script>
        $(document).ready(function() {
            $('#js-example-basic-roles').select2({});
            $('#js-example-basic-roles').val(@json($ur_roles));
            $('#js-example-basic-roles').trigger('change');

        });
    </script>
@endpush
