<div>
    @component('common.breadcrumb', ['addBtn' => true, 'permission_create' => 'Companies_create', 'breadcrumb_show' => $breadcrumb_show])
        @slot('breadcrumb_title')
            <h3>{{ $componentName }} | {{ $pageTitle }}</h3>
        @endslot
        <li class="breadcrumb-item">Administración</li>
        <li class="breadcrumb-item active">Empresa</li>
    @endcomponent
    @include('common.searchbox')
    <div class="container-fluid">
        <div class="row layout-top-spacing">
            <div class="col-sm-12">
                <div class="card">
                    <div class="table-responsive">
                        <table class="table">
                            <thead class="bg-primary">
                                <tr>
                                    <th scope="col">ID</th>
                                    <th scope="col">NOMBRE @include('common.orderby', ['column' => 'name'])</th>
                                    <th scope="col" class="text-center">PLAN</th>
                                    <th scope="col" class="text-center">CIUDAD</th>
                                    <th scope="col" class="text-center">TELÉFONO</th>
                                    <th scope="col" class="text-center">LOGO</th>
                                    <th scope="col" class="text-center">ACCIONES</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach ($companies as $item)
                                    <tr>
                                        <td>{{ $item->id }}</td>
                                        <td>{{ $item->name }}</td>
                                        <td class="text-center">{{ $item->plan_name }}</td>
                                        <td class="text-center">{{ $item->city_name }}</td>
                                        <td class="text-center">{{ $item->phone }}</td>
                                        <td class="text-center">
                                            <img src="{{ asset('storage/companies/'.$item->imagen) }}" alt="imagen"  class="rounded img-h-50">
                                        </td>
                                        <td class="text-center">
                                            @can('Companies_update')
                                            <a href="javascript:void(0)" wire:click="Edit({{ $item->id }})"
                                                class="btn btn-outline-primary" title="Editar">
                                                <i class="fas fa-edit"></i>
                                            </a>
                                            @endcan
                                            @can('Companies_delete')
                                            <a href="javascript:void(0)" onclick="Confirm('{{ $item->id }}')"
                                                class="btn btn-outline-danger " title="Eliminar">
                                                <i class="fas fa-trash"></i>
                                            </a>
                                            @endcan
                                            @can('Companies_add_users')
                                            <a href="{{ route('empresas.usuarios', $item) }}"
                                                class="btn btn-outline-primary " title="Agregar usuarios">
                                                <i class="fas fa-user-plus"></i>
                                            </a>
                                            @endcan
                                        </td>
                                    </tr>
                                @endforeach
                            </tbody>
                        </table>
                        {{ $companies->links() }}
                    </div>
                </div>
            </div>
        </div>
        @include('livewire.companies.form')
    </div>
</div>
@include('common.scriptsCompStandar')
<script>
    document.addEventListener('DOMContentLoaded', function() {
        window.livewire.on('user-withCompanies', msg => {
            noty(msg)
        })
    });
</script>
