I have the reply relationship with like & unlike model. User can like for their best reply and unlike for bad reply. The like & unlike relationship is almost same,just store in different table. Now i want to get the replies that having most like & reply that having most unlike, compare them and show only the replies which have most number of vote. How can i achieve it?
In my Discussion Model
public function replies(){
return $this->hasMany('App\Forum\Reply');
}
In Reply Model
public function discussion(){
return $this->belongsTo('App\Forum\Discussion');
}
public function user(){
return $this->belongsTo('App\User');
}
public function likes(){
return $this->hasMany('App\Forum\Like');
}
In the like model
public function user(){
return $this->belongsTo('App\User');
}
public function reply(){
return $this->belongsTo('App\Forum\Reply');
}