index.blade.php 2.65 KB
@extends('layout.admin', ['title' => 'Товары'])

@section('content')
    <div class="profile-block-wrapper">
        <div class="profile-block">
            <h2 class="modal-auth__title_">
                Товары
            </h2><br>
            <a href="{{ route('admin.goods.create') }}" class="btn banner-container__button" style="margin: 0px;">
                Создать товар
            </a><br><br>

            <table class="table" style="width: 100%">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>Фото</th>
                    <th>Категория</th>
                    <th>Товар</th>
                    <th>Дата создания</th>
                    <th>Действия</th>
                </tr>
                </thead>
                <tbody>
                @if ($goods->count())
                    @foreach($goods as $good)
                        <tr>
                            <td>{{ $good->id }}</td>
                            <td><? if (empty($good->image)) {?>Нет фото<?} else {?>
                            <!--<img src="/storage/app/public/<?//=$area->foto_main; //=asset(Storage::url($area->foto_main))?>" width="100px"/>-->
                                <img src="<?=asset(Storage::url($good->image))?>" width="100px"/>
                                <?}?></td>
                            <td>{{ $good->category->name }}</td>
                            <td>{{ $good->title }}</td>
                            <td>{{ $good->created_at }}</td>
                            <td> <form action="{{ route('admin.goods.destroy', $good) }}" method="POST">
                                    <a  href="{{ route('admin.goods.edit', ['good' => $good->id]) }}">
                                        Редактировать
                                    </a> |
                                    @csrf
                                    @method('DELETE')
                                    <input class=" btn-danger" type="submit" value="Удалить">
                                </form>
                            </td>
                        </tr>
                    @endforeach
                @else
                    <tr>
                        <td>-</td>
                        <td>-</td>
                        <td>-</td>
                        <td>-</td>
                        <td>-</td>
                        <td>-</td>
                    </tr>
                @endif

                </tbody>
            </table>

            {{ $goods->onEachSide(1)->links('catalogs.paginate') }}

        </div>
    </div>
    <br><br>
@endsection