I recieve correctly this two messages , but I need to JOIN this two results with Laravel5.
Could anyone helps to me ? Or it's any possibilities to doing this with other form?
$mensajes = Messageuser::find(1)->conversaciones()->get();
$mensajes2 = Messageuser::find(4)->conversaciones()->get();
echo $mensajes;
echo $mensajes2;
UPDATE
The MessageUser
use Illuminate\Database\Eloquent\Model;
class MessageUser extends Model {
protected $table ="message_user";
public function conversaciones(){
return $this->hasMany('App\Message','id_message','id');
}
}
The Message model
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Message extends Model {
protected $table="messages";
public function chat()
{
return $this->belongsTo('App\MessageUser','id');
}
}
UPDATED2
When I tried to sort in the view appear Illegal offset type
$mensajes = Messageuser::find(1)->conversaciones()->get();
$mensajes2 = Messageuser::find(4)->conversaciones()->get();
$mensajes = $mensajes->keyBy('created_at');
$prueba = $mensajes->merge($mensajes2->keyBy('created_at'));
return view('admin.msj')->with('pruebas',$prueba);