<div class="box">
    <div class="box-header">
        <h3 class="box-title">

        </h3>

    </div>
    <!-- /.box-header -->
    <div class="box-body table-responsive no-padding">
        <table class="table table-hover">
            <tbody>
                <tr>
                    <th colspan="2">ID</th>
                    <th>Nom</th>
                    <th>Type</th>
                    <th>Obligatoire</th>
                    <th>Afficher dans le filtre</th>
                    <th>Multi-valeurs</th>
                    <th>Unité</th>
                    <th style="width: 150px;" class="text-right">Action</th>
                </tr>
                @php
                     $type_array = [
                        "text" => "Text",
                        "long_text" => "Long text",
                        "number" => "Numérique",
                        "interval" => "Min/Max",
                        "boolean" => "Oui/Non",
                        "select" => "Liste de choix"
                     ]
                 @endphp
                @foreach($attributes as $attribute)
                <tr>
                    <td colspan="2">{{ $attribute->id }}</td>
                    <td>
                        {{ $attribute->name }} 
                    </td>
                    <td>{{ $type_array[$attribute->type] }}</td>
                    <td>{{ ($attribute->required)?'Oui':'Non' }}</td>
                    <td>{{ ($attribute->filtrable)?'Oui':'Non' }}</td>
                    <td>
                        @if($attribute->type == "select")
                        {{ ($attribute->multi_value)?'Oui':'Non' }}
                        @endif
                    </td>
                    <td>{{ $attribute->unite }}</td>
                    <td class="text-right">
                        @if($attribute->type == "select" && $attribute->multi_value == "0")
                        <a href="{{ route('backend.attributes.sub.create', [$category->id ,$attribute->id]) }}"
                            data-toggle="modal" data-target="#modal" class="btn btn-sm btn-success">
                            <i class="fa fa-plus" aria-hidden="true"></i> Ajouter un sous-attribut
                        </a>
                        @endif

                        <a href="{{ route('backend.attributes.edit', $attribute->id) }}" data-toggle="modal"
                            data-target="#modal" class="btn btn-sm btn-icon btn-primary">
                            <i class="fa fa-edit" aria-hidden="true"></i>
                        </a>
                        <a href="{{ route('backend.attributes.delete', $attribute->id) }}" class="btn btn-sm btn-icon btn-danger"
                            data-confirm="delete"><i class="fa fa-trash" aria-hidden="true"></i></a>

                    </td>
                </tr>
                 
                @foreach($attribute->childs as $sub_attribute)
                <tr style="background-color: #e4e4e4;">
                    <td><i class="fa fa-angle-right" aria-hidden="true"></i>
                    </td>
                    <td>{{ $sub_attribute->id }}</td>
                    <td>
                        <strong>{{ $sub_attribute->parent_value }}</strong> > {{ $sub_attribute->name }} 
                    </td>
                    <td>{{ $type_array[$sub_attribute->type] }}</td>
                    <td>{{ ($sub_attribute->required)?'Oui':'Non' }}</td>
                    <td>{{ ($sub_attribute->filtrable)?'Oui':'Non' }}</td>
                    <td>
                        @if($sub_attribute->type == "select")
                        {{ ($sub_attribute->multi_value)?'Oui':'Non' }}
                        @endif
                    </td>
                    <td>{{ $sub_attribute->unite }}</td>
                    <td class="text-right">
                        <a href="{{ route('backend.attributes.edit', $sub_attribute->id) }}" data-toggle="modal"
                            data-target="#modal" class="btn btn-icon btn-sm btn-primary">
                            <i class="fa fa-edit" aria-hidden="true"></i>
                        </a>
                        <a href="{{ route('backend.attributes.delete', $sub_attribute->id) }}" class="btn btn-icon btn-sm btn-danger"
                            data-confirm="delete"><i class="fa fa-trash" aria-hidden="true"></i></a>

                    </td>
                </tr>
                @endforeach
                @endforeach
            </tbody>
        </table>
    </div>
    <!-- /.box-body -->
    <div class="box-footer clearfix">
    </div>
</div>
<!-- /.box -->

<style>
    .table {
        font-size: 14px !important;
    }
</style>