@extends('admin.layout.index')
@push('css-head')
@endpush
@section('content')
<!-- Page header -->
<div class="page-header page-header-light">
    <div class="breadcrumb-line breadcrumb-line-light header-elements-md-inline">
        <div class="d-flex">
            <div class="breadcrumb">
                <a href="{{url('/admin')}}" class="breadcrumb-item"><i class="icon-home2 mr-2"></i> Dashboard</a>
                <a href="{{url('/admin/roles')}}" class="breadcrumb-item"> Roles</a>
                <span class="breadcrumb-item active">View</span>
            </div>
        </div>
    </div>
</div>
<!-- /page header -->

<!-- Content area -->
<div class="content">
    <div class="card">
        <div class="table-responsive">
            <table class="table">
                <tbody>
                    <tr>
                        <td class="font-weight-bold">Name:</td>
                        <td>{{ $role->name }}</td>
                    </tr>
                    <tr>
                        <td class="font-weight-bold">Permissions:</td>
                        <td>
                            <ul>
                                @foreach($permissions as $key=>$row)
                                @if(count($row['childs']) > 0)
                                    <li>{{ $row['parent']->display_name }}</li>
                                    <ul>
                                        @foreach($row['childs'] as $child)
                                        <li>{{$child->display_name}}</li>
                                        @endforeach
                                    </ul>
                                @else
                                <li>{{ $row['parent']->display_name }}</li>
                                @endif
                                @endforeach
                            </ul>
                        </td>
                    </tr>
                    <tr>
                        <td class="font-weight-bold">Created at:</td>
                        <td>{{date('F j, y h:i a', strtotime($role->created_at))}}</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
<!-- /content area -->
@endsection

@push('scripts')
@endpush