@php use App\Models\Role;use Carbon\Carbon; @endphp
@extends('adminlte::page')

@section('title', 'IPRS | Roles')

@section('content_header')
    <h3>Edit Role</h3>
@stop

@section('plugins.Datatables', true)

@section('content')

    {{-- Setup data for datatables --}}
    @php
        $headings = [
            'ID',
            'Role Name',
            'Actions'
        ];
    @endphp

    <x-adminlte-card>
        <x-adminlte-datatable id="clients-table" :heads="$headings" striped hoverable bordered>
                <tr>
                    <td>{{ $role->id }}</td>
                    <td>{{ $role->name }}</td>
                    <td>
                        <nobr>
                            <a href="{{ route('role.edit', ['role' => $role->id ]) }}"
                               class="btn btn-xs btn-default text-primary mx-1 shadow" title="Edit">
                                <i class="fa fa-lg fa-fw fa-pen"></i>
                            </a>
                            <a href="{{ route('role.show', ['role' => $role->id ]) }}"
                               class="btn btn-primary btn-sm text-white mx-1" title="Permissions">
                                Permissions
                            </a>
                        </nobr>
                    </td>
                </tr>
        </x-adminlte-datatable>
    </x-adminlte-card>

    <form method="POST" action="{{ route('role.update', ['role' => $role->id]) }}">
        @csrf
        @method('PATCH')
            <!-- Modal -->
            <div class="modal fade" id="roleUpdateModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" >
                <div class="modal-dialog modal-dialog-centered" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title font-weight-normal" id="modalLabel">Edit Role</h5>
                            <button type="button" class="btn-close text-dark" data-bs-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <div class="modal-body permModalBody">
                            <x-adminlte-input type="text" name="role_name" value="{{ $role->name }}" fgroup-class="col-md-12"/>
                        </div>
                        <div class="modal-footer permModalFooter">
                            <a href="{{ route('role.index') }}" class="btn bg-gradient-secondary" data-bs-dismiss="modal">Cancel</a>
                            <input type="submit" class="btn bg-gradient-success" value="Save Changes">
                        </div>
                    </div>
                </div>
            </div>
    </form>
@stop

@section('js')
    <script>
        $(window).on('load', function() {
           $('#roleUpdateModal').modal('show');
        });
    </script>
@stop
