<x-app-layout>
    @section('title')
        Role Edit
    @endsection
    <!-- DataTales Example -->
    <div class="row">
        <div class="col-md-12 m-auto">
            <h1 class="h3 mb-2 text-gray-800">
                <a href="{{ route('admin.roles.index') }}" class="btn btn-primary"><i class="fas fa-list"
                        aria-hidden="true"></i> Listing Role
                </a>
            </h1>

            {{-- @include('admin.layouts.partials.validation') --}}

            <div class="card shadow mb-4">
                <div class="card-header py-3">
                    <h6 class="m-0 font-weight-bold text-primary">
                        Listing Role Form
                    </h6>
                </div>
                <div class="card-body">
                    <form id="quickForm" novalidate="novalidate" method="POST" action="{{ route('admin.roles.update',$role->id)}}">
                        @csrf
                        @method('put')

                        <div class="form-group">
                            <label for="name">Role Name</label>
                            <input type="text" class="form-control @error('name') is-invalid @enderror" id="role_name" name="name"
                                                placeholder="Role Name" value="{{ old('name',$role->name) }}">
                            @error('name')
                                <p class="alert alert-danger">{{ $message }}</p>
                            @enderror
                        </div>

                        <div class="container-fluid">
                            <div class="row">
                                @foreach ($permissions as $permission)
                                    <div class="col-lg-3 mb-1">
                                        <input type="checkbox" class="form-check-input" name="permissions[]" id="checkPermission{{ $permission->id }}" value="{{$permission->id}}" name="permissions[]" @if(count($role->permissions->where('id',$permission->id)))
                                        checked
                                        @endif>
                                        <label class="form-check-label" for="checkPermission{{ $permission->id }}">{{ $permission->name }}</label>
                                    </div>
                                @endforeach
                            </div>
                        </div>

                        {{-- <div class="form-group">
                            @foreach($permissions as $permission)
                                <div class="form-check mr-1" style="display: inline-block !important">
                                    <input type="checkbox" class="form-check-input" name="permissions[]" id="checkPermission{{ $permission->id }}" value="{{$permission->id}}" name="permissions[]" @if(count($role->permissions->where('id',$permission->id)))
                                    checked
                                    @endif>
                                    <label class="form-check-label" for="checkPermission{{ $permission->id }}">{{ $permission->name }}</label>
                                </div>
                            @endforeach
                        </div> --}}
                        <button type="submit" class="btn btn-success">
                            Update
                        </button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</x-app-layout>
