@extends('back-end.master.app')
@section('title', 'Update User')
@section('body')
    <main class="app-content">
        <div class="row">
            <div class="col-md-12">
                <div class="tile">
                    <div class="tile-title-w-btn">
                        <h3 class="title">Edit </h3>
                        <div class="btn-group" role="group">
                            <a href="{{ route('system_user.index') }}" class="btn btn-outline-primary">
                                <i class="fa fa-list-alt"></i> List
                            </a>
                        </div>
                    </div>
                    <hr />
                    <div class="tile-body row">
                        <div class="col-md-8 offset-md-2">
                            <form method="POST" action="{{ route('system_user.update', $admin->id) }}"
                                enctype="multipart/form-data">
                                @csrf
                                @method('PUT')
                                <div class="form-group row">
                                    <label for="name"
                                        class="col-md-4 col-form-label text-md-right">{{ __('Name') }}</label>
                                    <div class="col-md-6">
                                        <input id="name" type="text"
                                            class="form-control @error('name') is-invalid @enderror" name="name"
                                            value="{{ $admin->name }}" required autocomplete="name" autofocus>

                                        @error('name')
                                            <span class="invalid-feedback" role="alert">
                                                <strong>{{ $message }}</strong>
                                            </span>
                                        @enderror
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label for="email"
                                        class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>

                                    <div class="col-md-6">
                                        <input id="email" type="email"
                                            class="form-control @error('email') is-invalid @enderror" name="email"
                                            value="{{ $admin->email }}" required autocomplete="email">

                                        @error('email')
                                            <span class="invalid-feedback" role="alert">
                                                <strong>{{ $message }}</strong>
                                            </span>
                                        @enderror
                                    </div>
                                </div>
                                <div class="from-group row">
                                    @php
                                        $adminrole = [];
                                        foreach ($adminRole as $row) {
                                            $adminrole[] = $row->id;
                                        }
                                    @endphp
                                    <label for="email"
                                        class="col-md-4 col-form-label text-md-right">{{ __('Roles') }}</label>
                                    <div class="col-md-6">
                                        <select class=" form-control select2-multiple" multiple="multiple" name="roles[]"
                                            multiple data-placeholder="Choose ...">
                                            @foreach ($roles as $roles)
                                                <option value="{{ $roles->id }}"
                                                    @if (in_array($roles->id, $adminrole)) {{ 'selected' }} @endif>
                                                    {{ $roles->name }}</option>
                                            @endforeach
                                        </select>
                                        @error('image')
                                            <span class="invalid-feedback" role="alert">
                                                <strong>{{ $message }}</strong>
                                            </span>
                                        @enderror
                                    </div>
                                </div>
                                <br>

                                <div class="form-group row">
                                    <label for="password"
                                        class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>

                                    <div class="col-md-6">
                                        <input id="password" type="password"
                                            class="form-control @error('password') is-invalid @enderror" name="password"
                                            autocomplete="new-password">

                                        @error('password')
                                            <span class="invalid-feedback" role="alert">
                                                <strong>{{ $message }}</strong>
                                            </span>
                                        @enderror
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label for="password-confirm"
                                        class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</label>

                                    <div class="col-md-6">
                                        <input id="password-confirm" type="password" class="form-control"
                                            name="password-confirm" autocomplete="new-password">
                                    </div>
                                </div>


                                <div class="form-group row mb-0">
                                    <div class="col-md-6 offset-md-4">
                                        <button type="submit" class="btn btn-primary">
                                            {{ __('Update') }}
                                        </button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </main>

@endsection


@section('pageJs')
    <script type="text/javascript">
        $(".app-menu").removeClass("active");
        $("#nav_account").addClass("active");
        $("#nav_accounti").addClass("is-expanded");
        $("#nav_user").addClass("active");
    </script>
@endsection
