i have this 2 queries
$a = Message::where('conversation_id',$id)->where('user_id',$user->id)->where('s_1',1)
->get();
$b = Message::where('user_id',$conversation->recipients()->last()->user->id)->where('s_1',1)
->get();
$result = $a->merge($b);
$messages = $result;
all well i pass the var messages to the view, but in the view the method render or links dont work to paginate the results:
<table class="table table-hover">
@foreach($messages as $i => $message)
<tr>
<td>
<img src="{{$avatar[$message->user->username]}}" class="aoi pull-left" />
<a href="{{route('profile',[$message->user->username])}}">{{ $message->user->name }}</a>
- <script>
moment.locale("es");
document.writeln(moment.utc("{{ $message->created_at }}", "YYYYMMDD hh:mm:ss").fromNow());
</script>
<br>
{{ $message->body }}
</td>
</tr>
@endforeach
</table>
{!! str_replace('/?', '?', $messages->render()) !!}
you have to use the paginate() function for getting your record.
you should try this.
$b = Message::where('user_id',$conversation->recipients()->last()->user->id)->where('s_1',1)
->orderBy('user_id','desc')->paginate(10);
this will automatically get() the record matching to your query, and you only have to do for the pagination like ,
{{$b->appends(request()->input())->links()}}
this will automatically give the links to next pages if record will be more then your paginate limit (10) .