@extends('app.admin.layout.layout')
@section('title',__('Edit role'))
@section('content')
    <style>
        .form-control{
            border-radius: 10px;
            border: 1px solid #7b7bff;
            box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;        }
        .form-label{
            font-family: "Helvetica Neue", "Helvetica", "Arial", sans-serif;
        }

        .layout-top-spacing{
            margin: 20px;
            border-radius: 15px;
            box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
        }
        .form-select{
            background-image: none !important;
        }
    </style>
    <div class="card layout-top-spacing">
        <div class="card-header d-flex justify-content-between align-items-center" style="background-color: #ff2a0e !important">
            <h5 class="m-0" style="color: white">@lang('Edit role')</h5>
            <a class="btn btn-secondary" href="{{route('admin:roles.index')}}">@lang('Back')</a>
        </div>
        <div class="card-body">
            <form @class(["row needs-validation","was-validated" => $errors->any()]) action="{{route('admin:roles.update',$role->getAttribute('id'))}}" method="post" novalidate>
                @csrf
                @method('PUT')

                <x-admin.form.input
                        :label="__('Role name')"
                        name="name"
                        :value="old('name',$role->getAttribute('name'))"
                        required/>

                <table class="table table-bordered table-striped table-vcenter js-dataTable-full-pagination">
                    <tbody>
                    @foreach ($permissions as $permission)
                        <tr class="border-bottom-secondary">
                            <td>
                                @lang(ucfirst($permission->getAttribute('name')))
                            </td>
                            <td>
                                <div class="form-check form-switch">
                                    <input name="permissions[]" class="form-check-input" id="permission{{$permission->getAttribute('id')}}" type="checkbox" role="switch" value="{{$permission->getAttribute('name')}}" @checked(in_array($permission->getAttribute('name'), old('permissions', array_values($role->permissions->pluck('name')->toArray()))))>
                                </div>
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>

                <x-admin.form.submit-button button-text="Update"/>

            </form>
        </div>
    </div>
@endsection
