mercredi 16 mars 2016

laravel sidebar jscroll query

i have simlar query like here.i want paginate query but it already has get.my query is

$left_data = $this->getConversationSorted();
protected function getConversationSorted()
{
    $con = Conversation::leftjoin('messages', function ($join) {
        $join->on('conversations.id', '=', 'messages.conversation_id');
    })->where(function ($q) {
        $q->where('conversations.from_user', '=', $this->user->id)
            ->orWhere('conversations.to_user', '=', $this->user->id);
    })->where('conversations.type','>','0')->groupby('conversations.id')
        ->orderby('messages.created_at', SORT_DESC)
        ->get(['conversations.*','messages.conversation_id']);

    return $con;
}

my view

<div class="tab-content col-xs-12 chat_head_list">
<div class="search_container">
    <div class="right-inner-addon">
        {!! Form::open() !!}
        <i class="glyphicon glyphicon-search"></i>
        {!! Form::text('id_search','',array('class' => 'form-control id_search' , 'placeholder' => 'Search...')) !!}
        {!! Form::close() !!}
        <div class="form-group" style="margin-top: 5px;">
            <select name="interaction_type" id="interaction_type" class="form-control">
                <option value="0" selected>All Conversations</option>
                <option value="1">Profile Evaluation</option>
                <option value="2">Recruiter Watchlist</option>
                <option value="3">Direct Messages</option>
                <option value="4">Messages</option>
            </select>
        </div>
    </div>
</div>
<ul class="nav nav-stacked chat_head_block">
    @foreach($left_data as $left)
       <div class="leftside">
        @if($left->from_user  !== NULL && $left->to_user !== NULL)
            <li class="@if($con_id == $left->conversation_id)active_convo @endif {{ $left->type }}" >
                <div class="media">
                    <div class="media-left media-top">
                        {{--@if((!empty($left->messages))) @foreach($left->messages as $l) @if($l->messages->seen == '0') style="background-color: #F5F5F5" @endif @endforeach @endif--}}
                        <a class="article_list_img" href="{{ route('profileevaluation.conversation',array('id' => $left->id)) }}" >
                            @if($user->id == $left->to_user)
                                @if(!empty($left->fromUser->getavatar->avatar))
                                    <img src="{{ asset('/img/no-image.jpg') }}" class="lazy" data-src="{{ asset('/img/frontend/useravatar/'.$left->fromUser->getavatar->avatar) }}">
                                @else
                                    @if($left->fromUser->providers->isEmpty())
                                        <img src="{{ asset('/img/no-image.jpg') }}" class="lazy"  data-src="{{ asset('/img/no-image.jpg') }}" >
                                    @else
                                        <img src="{{ asset('/img/no-image.jpg') }}">
                                    @endif
                                @endif
                            @else
                                @if(!empty($left->toUser->getavatar->avatar))
                                    <img src="{{ asset('/img/no-image.jpg') }}" class="lazy" data-src="{{ asset('/img/frontend/useravatar/'.$left->toUser->getavatar->avatar) }}">
                                @else
                                    @if($left->toUser->providers->isEmpty())
                                        <img src="{{ asset('/img/no-image.jpg') }}" class="lazy" data-src="{{ asset('/img/no-image.jpg') }}">
                                    @else
                                        <img src="{{ asset('/img/no-image.jpg') }}" class="lazy" data-src="{{ $left->toUser->providers[0]->avatar }}">
                                    @endif
                                @endif
                            @endif
                        </a>
                    </div>
                    <div class="media-body">
                        <div class="body_title">
                            <a href="{{ route('profileevaluation.conversation',array('id' => $left->id)) }}" style="text-decoration: none">
                                @if($left->type == 1)
                                    Admissions Counselling from
                                @elseif($left->type == 2)
                                    Recruiter Interaction from
                                @elseif($left->type == 3)
                                    Direct message from
                                @elseif($left->type == 4)
                                    Message
                                @endif
                                <br>
                                @if($left->from_user != $user->id)
                                    @if(!empty($left->fromUser->name))
                                        {!! $left->fromUser->name !!}
                                    @endif
                                @else
                                    @if(!empty($left->toUser->name))
                                        {!! $left->toUser->name !!}
                                    @endif
                                @endif
                            </a>
                        </div>
                        <div class="body-count">
                            @if($left->messages->count() != '0')
                                <span style="font-weight: bold">{{ $left->messages->count() }} messages</span>
                            @endif
                        </div>
                    </div>
                </div>
            </li>
        @endif
    @endforeach
        {!! $left_data->render() !!}
       </div>
</ul>

i want jscroll div.media part.i want laravel query where both pagination and get can be used.i m using laravel 5.1.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire