detail_new.blade.php 5.57 KB
@extends('layout.frontend', ['title' => $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('education') }}",
                data: "sort="+val_+"&block=1",
                success: function (data) {
                    console.log('Выбор сортировки');
                    console.log(data);
                    $('#block').html(data);
                    history.pushState({}, '', "{{ route('education') }}?sort="+val_+"@if (isset($_GET['page']))&page={{ $_GET['page'] }}@endif");
                },
                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');
            console.log(sel);
            console.log(key);

            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">
            <div class="thing__body">
                <ul class="breadcrumbs thing__breadcrumbs">
                    <li><a href="{{ route('index') }}">Главная</a></li>
                    <li><a href="{{ route('news') }}">Новости и статьи</a></li>
                    <li><b>{{ $title }}</b></li>
                </ul>

                @if (empty($Query[0]->image))
                    <img src="{{ asset('/images/default_ship.jpg') }}" alt="{{ $title }}" class="thing__pic thing__pic_two">
                @else
                    <img src="{{ asset(Storage::url($Query[0]->image)) }}" alt="{{ $title }}" class="thing__pic thing__pic_two">
                @endif
                <time class="thing__date">{{ date('d.m.Y H:i:s', strtotime($Query[0]->created_at)) }}</time>
                <h1 class="thing__title">{{ $title }}</h1>
                <p class="thing__text">{!! mb_strimwidth($Query[0]->text, 0, 100, "...") !!}</p>
            </div>
        </div>
    </section>


    <main class="main">
            <div class="container">
                <div class="main__content">
                    <div class="main__content-item">
                        <h2>{{ $Query[0]->title }}</h2>
                        <p>{!! $Query[0]->text !!}</p>
                    </div>
                </div>
            </div>
    </main>
        <section class="news">
            <div class="container">
                <div class="news__toper">
                    <div class="title">Новости и статьи</div>
                    <div class="navs">
                        <button class="js-news-swiper-button-prev">
                            <svg class="rotate180">
                                <use xlink:href="images/sprite.svg#arrow"></use>
                            </svg>
                        </button>
                        <button class="js-news-swiper-button-next">
                            <svg>
                                <use xlink:href="images/sprite.svg#arrow"></use>
                            </svg>
                        </button>
                    </div>
                </div>
                <div class="swiper js-news-swiper">
                    <div class="swiper-wrapper">
                        @if ($All_Query->count())
                        @foreach($All_Query as $Q_item)
                        <div class="swiper-slide">
                            <div class="news__item">
                                <img src="{{ asset(Storage::url($Q_item->image)) }}" alt="{{ $Q_item->title }}" class="news__item-pic">
                                <div class="news__item-body">
                                    <time datetime="{{ date('d.m.Y H:i:s', strtotime($Q_item->created_at)) }}" class="news__item-date">{{ date('d.m.Y H:i:s', strtotime($Q_item->created_at)) }}</time>
                                    <span class="news__item-title">{{ $Q_item->title }}</span>
                                    <span class="news__item-text">{!! $Q_item->text !!}</span>
                                    <a href="{{ route('detail_new', ['new' => $Q_item->id]) }}" class="news__item-more button button_light">Читать далее</a>
                                </div>
                            </div>
                        </div>
                        @endforeach
                        @endif
                    </div>
                    <div class="swiper-pagination"></div>
                </div>
                <a href="{{ route('news') }}" class="news__all button button_light">Все новости</a>
            </div>
        </section>
</div>
@endsection