messages.blade.php 9.63 KB
@extends('layout.frontend', ['title' => 'Мои сообщения - РекаМоре'])

@section('scripts')

@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('workers.emblema')

                    </div>

                    @include('workers.menu', ['item' => 2])
                </div>
                <div class="cabinet__body">
                    <div class="cabinet__body-item">
                        <h2 class="title cabinet__title">Сообщения</h2>
                    </div>
                    <div class="cabinet__body-item">
                        <div class="cabinet__filters">
                            <div class="cabinet__filters-item">
                                <div class="cabinet__filters-buttons">
                                    <a href="{{ route('worker.messages', ['type_message' => 'input']) }}" class="button button_light @if ($type_message == 'input') active @endif">Входящие ({{ $count_input }})</a>
                                    <a href="{{ route('worker.messages', ['type_message' => 'output']) }}" class="button button_light @if ($type_message == 'output') active @endif">Исходящие ({{ $count_output }})</a>
                                </div>
                            </div>
                            <!--<div class="cabinet__filters-item">
                                <div class="select">
                                    <select class="js-select2" id="sort_ajax" name="sort_ajax">
                                        <option value="default">Сортировка (по умолчанию)</option>
                                        <option value="name (asc)">По имени (возрастание)</option>
                                        <option value="name (desc)">По имени (убывание)</option>
                                        <option value="created_at (asc)">По дате (возрастание)</option>
                                        <option value="created_at (desc)">По дате (убывание)</option>
                                    </select>
                                </div>
                            </div>-->
                        </div>
                        @if ($messages->count())
                            @foreach($messages as $it)
                                <div class="messages__item">
                                    <div class="messages__item-info">
                                        <!--<pre> print_r(asset(Storage::url($it->user_from->employers[0]->logo))) }}</pre>-->
                                        <div class="messages__item-photo">
                                            <svg>
                                                <use xlink:href="{{ asset('images/sprite.svg#pic') }}"></use>
                                            </svg>
                                            <!-- Комментарий: обновление структуры вывода картинок, все корректное -->
                                            @if ($type_message == 'input')
                                                @if ($it->user_from->is_worker)
                                                    @if (isset($it->user_from->workers[0]->photo))
                                                        <img src="{{ asset(Storage::url($it->user_to->workers[0]->photo)) }}" alt="">
                                                    @else
                                                        <img src="{{ asset('images/default_man.jpg') }}" alt="">
                                                    @endif
                                                @else
                                                    @if (isset($it->user_from->employers[0]->logo))
                                                        <img src="{{ asset(Storage::url($it->user_from->employers[0]->logo)) }}" alt="">
                                                    @else
                                                        <img src=" asset('images/default_man.jpg') }}" alt="">
                                                    @endif
                                                @endif
                                            @endif

                                            <!-- Обновление исходящих сообщений - фотографии компании и работника -->
                                            @if ($type_message == 'output')
                                                @if ($it->user_from->is_worker)
                                                    @if (isset($it->user_from->workers[0]->photo))
                                                        <img src="{{ asset(Storage::url($it->user_from->workers[0]->photo)) }}" alt="">
                                                    @else
                                                        <img src="{{ asset('images/default_man.jpg') }}" alt="">
                                                    @endif
                                                @else
                                                    @if (isset($it->user_from->employers->logo))
                                                        <img src="{{ asset(Storage::url($it->user_from->employers->logo)) }}" alt="">
                                                    @else
                                                        <img src="{{ asset('images/default_man.jpg') }}" alt="">
                                                    @endif
                                                @endif
                                            @endif
                                        </div>
                                        <div class="messages__item-text">
                                            <div>
                                                От: @if (isset($it->user_from))
                                                    @if ($it->user_from->id !== $user_id)
                                                        <a href="{{ route('worker.dialog', ['user1' => $user_id, 'user2' => $it->user_from->id]) }}" style="text-decoration: underline">
                                                            {{ $it->user_from->surname." ".$it->user_from->name_man." ".$it->user_from->surname2." (".$it->user_from->id.")" }}
                                                        </a>
                                                    @else
                                                        {{ $it->user_from->surname." ".$it->user_from->name_man." ".$it->user_from->surname2." (".$it->user_from->id.")" }}
                                                    @endif
                                                @else
                                                    Удаленный пользователь
                                                @endif
                                                <br>
                                                К: @if (isset($it->user_to))
                                                    @if ($it->user_to->id !== $user_id)
                                                        <a href="{{ route('worker.dialog', ['user1' => $user_id, 'user2' => $it->user_to->id]) }}" style="text-decoration: underline">
                                                            {{ $it->user_to->surname." ".$it->user_to->name_man." ".$it->user_to->surname2." (".$it->user_to->id.")" }}
                                                        </a>
                                                    @else
                                                        {{ $it->user_to->surname." ".$it->user_to->name_man." ".$it->user_to->surname2." (".$it->user_to->id.")" }}
                                                    @endif
                                                @else
                                                    Удаленный пользователь
                                                @endif
                                            </div>
                                            <div><span>Вакансия:</span>@if (isset($it->vacancies)) {{ $it->vacancies->name." (".($it->vacancies->id).")" }} @else Удалена @endif</div>
                                            <div><span>Текст:</span>{{ $it->text }}</div>
                                        </div>
                                    </div>
                                    <div class="messages__item-date">{{ $it->created_at }}</div>
                                </div>
                            @endforeach

                            <div style="margin-top: 20px">
                                {{ $messages->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>
    </section>
    </div>
    <div>
@endsection