messages.blade.php 7.71 KB
@extends('layout.frontend', ['title' => 'Сообщения от пользователей - РекаМоре'])
@section('scripts')
    <script>
        console.log('Test system');
        $(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);
                }
            });
        });
    </script>
@endsection

@section('content')
    <section class="cabinet">
        <div class="container">
            <ul class="breadcrumbs cabinet__breadcrumbs">
                <li><a href="{{ route('index') }}">Главная</a></li>
                <li><b>Личный кабинет</b></li>
            </ul>
            <div class="cabinet__wrapper">
                <div class="cabinet__side">
                    <div class="cabinet__side-toper">
                        @include('employers.emblema')
                    </div>


                    @include('employers.menu', ['item' => 5])
                </div>

                <div class="cabinet__body">
                    <div class="cabinet__body-item">
                        <h2 class="title cabinet__title">Сообщения</h2>
                    </div>
                    <div class="cabinet__body-item">
                        <div class="messages">
                            <div class="messages__body">
                                @if ($chats->count())
                                    @foreach($chats as $chat)
                                        <div class="">
                                            <a class="messages__item hover-shadow" href="{{ route('employer.dialog', ['user1' => $chat->user_id, 'user2' => $chat->to_user_id, 'ad_employer' => 0]) }}">
                                                <div class="messages__item-info">
                                                    <div class="messages__item-photo">
                                                        @if (isset($chat->worker->photo))
                                                            <img src="{{ asset(Storage::url($chat->worker->photo)) }}" alt="">
                                                        @else
                                                            <img src="{{ asset('images/default_man.jpg') }}" alt="">
                                                        @endif
                                                    </div>
                                                    <div class="messages__item-text">
                                                        <div>
                                                            <b>
                                                            @if ($chat->employer && $chat->employer->name_company)
                                                                {{ $chat->employer->name_company }}
                                                            @else
                                                                {{ $chat->user->surname . ' ' . $chat->user->name_man . ' ' . $chat->user->surname2  }}
                                                            @endif
                                                            </b>
                                                        </div>
                                                        <div>
                                                            {{ $chat->last_message->text }}
                                                        </div>
                                                    </div>
                                                </div>

                                                <div class="messages__item-actions">
                                                    <div class="messages__item-date max-content">{{ date(' H:i, d.m.Y', strtotime($chat->created_at)) }}</div>
                                                    <div class="messages__item-buttons">
                                                        @if($chat->unread_messages_count > 0)
                                                            <div class="unread-messages-count mr-15">{{ $chat->unread_messages_count }}</div>
                                                        @endif

                                                        <button class="mr-15">
                                                            @if(intval($chat->is_fixed) == 1)
                                                                @include('svg.pin_on')
                                                            @else
                                                                @include('svg.pin_off')
                                                            @endif
                                                        </button>
                                                        <button class="">
                                                            <svg>
                                                                <use xlink:href="{{ asset('images/sprite.svg#del') }}"></use>
                                                            </svg>
                                                        </button>
                                                    </div>
                                                    <div class="clear"></div>
                                                </div>
                                            </a>
                                        </div>
                                    @endforeach
                                    <div style="margin-top: 20px">
                                        {{ $chats->onEachSide(0)->appends($_GET)->links('paginate') }}
                                    </div><!-- конец -->
                                @else
                                    <div class="notify">
                                        <svg>
                                            <use xlink:href="{{ asset('images/sprite.svg#i') }}"></use>
                                        </svg>
                                        <span>Сообщений не найдено</span>
                                    </div>
                                @endif
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
    </div>
@endsection