@extends('superadmin.layout')
@section('content')
    <!-- begin::main content -->

    <main class="main-content">

        <div class="container">

            <!-- begin::page header -->
            <div class="page-header">
                <h3>Add Permission of {{ $role->name }} Role</h3>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="{{ asset('superadmin/dashboard') }}">Dashboard</a></li>
                        <li class="breadcrumb-item">
                            <a href="{{ asset('superadmin/roles') }}">Roles</a>
                        </li>
                        <li class="breadcrumb-item">
                            <a href="{{ asset('superadmin/permission/' . Request::segment(3)) }}">Permission</a>
                        </li>
                        <li class="breadcrumb-item active" aria-current="page">Add Permission</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('superadmin/permission/' . Request::segment(3)) }}"
                                class="btn btn-primary pull-right text-white">
                                <i class="fa fa-list"></i>&nbsp;Permission List</a>
                        </div>
                        <div class="card-body">
                            <form action="{{ asset('superadmin/add-permission/' . Request::segment(3)) }}" method="post">
                                @csrf

                                {{-- Permissions --}}
                                @if (!empty($permissions))
                                    @foreach ($permissions as $permission)
                                        <div class="form-group">
                                            <div class="custom-control custom-checkbox">
                                                <input {{ $permission->hasPermission != null ? 'checked' : '' }}
                                                    type="checkbox" name="permission[]" value="{{ $permission->id }}"
                                                    class="custom-control-input" id="{{ $permission->slug }}">
                                                <label class="custom-control-label"
                                                    for="{{ $permission->slug }}">{{ $permission->name }}</label>
                                            </div>
                                        </div>
                                    @endforeach
                                @endif

                                <input type="hidden" name="role_id" value="{{ Request::segment(3) }}">

                                <button type="submit" class="btn btn-primary">Submit</button>
                            </form>
                        </div>
                    </div>



                </div>

            </div>

        </div>

    </main>
    <!-- end::main content -->
@endsection
@push('footer-script')
    <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>
@endpush
