Sunday, March 11, 2018

Show common date of messages in laravel - development

Show common date of messages in laravel

I use this package: https://github.com/musonza/chat
I have a function:

$messages = Chat::conversations($conversation)->for($user)->getMessages($limit, $request->page);

How I add common date in messages.blade.php?

Example:

—- 24 february (I need this date show) —-
12:02 Message 1
12:05 Message 2
14:05 Message 4
16:05 Message 2
17:05 Message 4
18:05 Message 2
19:05 Message 4
—- Today (I need this date show) —-
12:02 Hello
12:05 Hello again

My messages blade:

@foreach($messages as $message)
            <li data-mid="">
                <div class="row margin-left-none margin-right-none">
                    <div class="col-md-2 padding-right-none">
                        <div class="avatar-user text-center">
                                <img src="" alt="$message->sender->name">
                        </div>
                    </div>

                    <div class="col-md-10 padding-left-none">
                        <div class="user-name">
                            <span>
                                @if(Helper::getOnlineUser($message->sender->id))
                                <i data-toggle="tooltip" title="Online" class="material-icons online">fiber_manual_record</i>
                                @else 
                                <i data-toggle="tooltip" title="Offline" class="material-icons offline">fiber_manual_record</i>
                                @endif
                                <span class="date float-right"></span></span>
                        </div>
                        <div class="message">
                            
                        </div>
                    </div>
                </div>
            </li>
            @endforeach



from Laravel Questions and Answers https://laravelquestions.com/php/show-common-date-of-messages-in-laravel/
via Lzo Media

No comments:

Post a Comment