@extends('layouts.app')

@section('content')
    <div class="container">
        <div class="row">
            <div class="{{ $containerSize }}">
                @include('layouts.alerts')

                <div class="panel panel-default">
                    <div class="panel-heading"><strong>@lang($heading) {{ $customHeading?$singular:'' }}</strong></div>
                    @if($result !== null)
                        <div class="panel-body">
                            <div class="table-responsive">
                                <div class="col-md-8 col-md-offset-2">
                                    <table class="table table-striped table-bordered">
                                        <thead>
                                        <tr>
                                            <th>
                                                @lang('Attribute')
                                            </th>
                                            <th>
                                                @lang('Value')
                                            </th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        @foreach($columns as $column)
                                            <tr>
                                                <td>
                                                    @lang($column)
                                                </td>
                                                <td>
                                                    {{ $result->$column ?: '-' }}
                                                </td>
                                            </tr>
                                        @endforeach
                                        </tbody>
                                    </table>
                                </div>
                                @if(count($result->parameters))
                                    <table class="table table-striped table-bordered">
                                        <thead>
                                        <tr>
                                            <th>
                                                @lang('Parameter Id')
                                            </th>
                                            <th>
                                                @lang('Parameter Name')
                                            </th>
                                            <th>
                                                @lang('Parameter Type')
                                            </th>
                                            <th>
                                                @lang('Max Value or Length')
                                            </th>
                                            <th>
                                                @lang('Unique')
                                            </th>
                                            <th>
                                                @lang('Required')
                                            </th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        @foreach($result->parameters as $parameter)
                                            <tr>
                                                @foreach($parameter as $parameterCharacteristic)
                                                    <td>
                                                        {{$parameterCharacteristic ?: '-'}}
                                                    </td>
                                                @endforeach
                                            </tr>
                                        @endforeach
                                        </tbody>
                                    </table>
                                @endif
                            </div>
                        </div>
                        @if($canEdit || $canDelete)

                            @if($canEdit && !$canDelete)
                                <div class="panel-footer text-center">
                                    <a class="btn btn-labeled btn-default"
                                       href="{{ route($router . '.edit', [
                                            'id' => $objectId
                                       ]) }}">
                                                        <span class="btn-label">
                                                            <i class="glyphicon glyphicon-edit"></i>
                                                            @lang('do.Edit')
                                                        </span>
                                    </a>
                                </div>
                            @endif
                            @if($canDelete)
                                <div class="panel-footer">
                                    <form action="{{ route($router . '.destroy', [
                                                        'id' => $objectId
                                                    ]) }}"
                                          method="post">
                                        {{ method_field('DELETE') }}
                                        {{ csrf_field() }}
                                        <button type="submit" class="btn btn-labeled btn-default">
                                            <span class="btn-label">
                                                <i class="glyphicon glyphicon-trash text-danger"></i>
                                                @lang('do.Delete')
                                            </span>
                                        </button>
                                        @if($canEdit)
                                            <div class="pull-right">
                                                <a class="btn btn-labeled btn-default"
                                                   href=" {!! route($router . '.edit', [
                                                        'id' => $objectId
                                                   ]) !!} ">
                                                        <span class="btn-label">
                                                            <i class="glyphicon glyphicon-edit"></i>
                                                            @lang('do.Edit')
                                                        </span>
                                                </a>
                                            </div>
                                        @endif
                                    </form>
                                </div>
                            @endif
                        @endif
                    @else
                        @lang($nothingFound)!
                    @endif
                </div>
            </div>
        </div>
@endsection
