I am working on social app front end Angualar, Backend laravel and with database Mongodb. I have model like:
Hoots
-----------------
- _id
- content
- publish_id
Article
-----------------
- _id
- content
- publish_id
Story
-----------------
- _id
- content
- publish_id
Publish
-----------------
- _id
- post_id
- type
- user_id
Post id in publish belongs to _id in hoots , article and story , where type signify wheather it is hoot , article or story.
I have Model like this
//Article model
class Article extends Eloquent {
public function getpublish(){
return $this->hasMany('Publish','post_id');
}
}
//Story model
class Story extends Eloquent {
public function get_publish(){
return $this->hasMany('Publish','post_id');
}
}
//Hoots model
class Hoots extends Eloquent {
public function get_publ(){
return $this->hasMany('Publish','post_id');
}
}
//Publish model
class Publish extends Eloquent {
public function getdata(){
return $this->BelongsTo('Hoots','Article','Story','publish_id');
}
}
I am using
Publish::with('getdata')->where('user_id',Auth::user()->id)->get();
using this i can only get publish data along with post_id corresponding data in one model i.e hoots only. I want this from all three tables.
I want to fetch publish model data with their corresponding post_id data.How can i accomplish this o single query using eloquent.