companies.blade.php 9.75 KB
@extends('layout.frontend', ['title' => 'Судоходные компании РекаМоре'])

@section('scripts')
    <script>
        $(document).on('change', '#sort_ajax', function() {
            var this_ = $(this);
            var val_ = this_.val();
            console.log('sort items '+val_);

            $.ajax({
                type: "GET",
                url: "{{ route('shipping_companies') }}",
                data: "sort="+val_+"&block=1",
                success: function (data) {
                    console.log('Выбор сортировки');
                    console.log(data);
                    $('#block_1').html(data);
                },
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                error: function (data) {
                    data = JSON.stringify(data);
                    console.log('Error: ' + data);
                }
            });

            $.ajax({
                type: "GET",
                url: "{{ route('shipping_companies') }}",
                data: "sort="+val_+"&block=2",
                success: function (data) {
                    console.log('Выбор сортировки2');
                    console.log(data);
                        history.pushState({}, '', "{{ route('shipping_companies') }}?sort="+val_+"@if (isset($_GET['page']))&page={{ $_GET['page'] }}@endif");
                        $('#block_2').html(data);
                },
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                error: function (data) {
                    data = JSON.stringify(data);
                    console.log('Error: ' + data);
                }
            });
        });

        $(document).ready(function(){
            var sel = $('#select2-sort_ajax-container');
            var key = getUrlParameter('sort');

            if (key !=='') {
                console.log(key);
                switch (key) {
                    case "default": sel.html('Сортировка (по умолчанию)'); break;
                    case "name_up": sel.html('По имени (возрастание)'); break;
                    case "name_down": sel.html('По дате (убывание)'); break;
                    case "created_at_up": sel.html('По дате (возрастание)'); break;
                    case "created_at_down": sel.html('По дате (убывание)'); break;
                }

            }
        });
    </script>
@endsection

@section('content')
<section class="thing">
    <div class="container">
        <form class="thing__body">
            @csrf
            <ul class="breadcrumbs thing__breadcrumbs">
                <li><a href="{{ route('index') }}">Главная</a></li>
                <li><b>Работодатели</b></li>
            </ul>
            <h1 class="thing__title">Работодатели</h1>
            <p class="thing__text">С другой стороны, социально-экономическое развитие не оставляет шанса для
                существующих финансовых и административных условий.</p>
            <div class="search thing__search">
                <input type="search" id="search" name="search" class="input" value="{{ (isset($_GET['search'])) ? $_GET['search'] : '' }}" placeholder="Введите наименование работодателя">
                <button type="submit" class="button">Найти</button>
                <span>
                    <svg>
                        <use xlink:href="{{ asset('images/sprite.svg#search') }}"></use>
                    </svg>
                </span>
            </div>
        </form>
    </div>
</section>
<main class="main">
    <div class="container">
        <div class="main__employers">
            <div class="filters">
                <div class="filters__label">Показано {{ $emps->firstItem() }} – {{ $emps->lastItem() }} из {{ $count_emps }} результатов поиска</div>
                <div class="filters__body">
                    <div class="select filters__select">
                        <select class="js-select2" id="sort_ajax" name="sort_ajax">
                            <option value="default">Сортировка (по умолчанию)</option>
                            <option value="name_up">По имени (возрастание)</option>
                            <option value="name_down">По имени (убывание)</option>
                            <option value="created_at_up">По дате (возрастание)</option>
                            <option value="created_at_down">По дате (убывание)</option>
                        </select>
                    </div>
                    <button type="button" class="filters__item active" data-tab="1">
                        <svg>
                            <use xlink:href="{{ asset('images/sprite.svg#grid-1') }}"></use>
                        </svg>
                    </button>
                    <button type="button" class="filters__item" data-tab="2">
                        <svg>
                            <use xlink:href="{{ asset('images/sprite.svg#grid-2') }}"></use>
                        </svg>
                    </button>
                </div>
            </div>
            <div class="main__employers-body showed" data-body="1" id="block_1" name="block_1">
                <div class="main__employers-one">
                @if ($emps->count())
                    @foreach($emps as $emp)
                    <div class="main__employers-item">
                                <span class="main__employers-item-inner">
                                    @if (!empty($emp->logo))
                                        <a href="{{ route('info_company', ['company' => $emp->id]) }}">
                                            <img src="{{ asset(Storage::url($emp->logo)) }}" alt="{{ $emp->name_company }}" class="main__employers-item-pic">
                                        </a>
                                    @else
                                        <a href="{{ route('info_company', ['company' => $emp->id]) }}">
                                            <img src="{{ asset('images/default_ship.jpg') }}" alt="{{ $emp->name_company }}" class="main__employers-item-pic">
                                        </a>
                                    @endif
                                    <span class="main__employers-item-body">
                                        <b>{{ $emp->name_company }}</b>
                                        <i>{{ $emp->ads->count() }} вакансия(ий)</i>
                                    </span>
                                </span>
                        <a href="{{ route('info_company', ['company' => $emp->id]) }}" class="button button_light main__employers-item-more">Подробнее</a>

                        @if ($emp->oficial_status == 1)
                        <span class="main__employers-item-label">
                            <svg>
                                <use xlink:href="images/sprite.svg#v"></use>
                            </svg>
                            <span>Компания одобрена сервисом rekamore.su</span>
                        </span>
                        @endif
                    </div>
                    @endforeach
                </div>

                {{ $emps->appends($_GET)->links('paginate') }}

                @else
                    <H2>Нет данных</H2>
                @endif

            </div>
            <div class="main__employers-body" data-body="2" id="block_2" name="block_2">
                @if ($emps->count())
                <div class="main__employers-two">
                        @foreach($emps as $emp)
                            <div class="main__employers-item">
                                <span class="main__employers-item-inner">
                                    @if (!empty($emp->logo))
                                        <img src="{{ asset(Storage::url($emp->logo)) }}" alt="{{ $emp->name_company }}" class="main__employers-item-pic">
                                    @else
                                        <img src="{{ asset('images/default_ship.jpg') }}" alt="{{ $emp->name_company }}" class="main__employers-item-pic">
                                    @endif
                                    <span class="main__employers-item-body">
                                        <b>{{ $emp->name_company }}</b>
                                        <i>{{ $emp->ads->count() }} вакансия(ий)</i>
                                    </span>
                                </span>
                                <a href="{{ route('info_company', ['company' => $emp->id]) }}" class="button button_light main__employers-item-more">Подробнее</a>
                                @if ($emp->oficial_status == 1)
                                <span class="main__employers-item-label">
                                    <svg>
                                        <use xlink:href="{{ asset('images/sprite.svg#v') }}"></use>
                                    </svg>
                                    <span>Компания одобрена сервисом rekamore.su</span>
                                </span>
                                @endif
                            </div>
                        @endforeach
                </div>
                {{ $emps->appends($_GET)->links('paginate') }}
                @else
                    <H2>Нет данных</H2>
                @endif
            </div>
        </div>
    </div>
</main>
@endsection