Within comment
resource
public static $searchRelations = [
'post' => ['title'],
'video' => ['title'],
];
And here is the comment
model
class Comment {
public function commentable() {
return $this->morphTo();
}
public function post() {
return $this
->belongsTo('App\Post', 'commentable_id')
->where('commentable_type', 'App\Post');
}
public function video() {
return $this
->belongsTo('App\Video', 'commentable_id')
->where('commentable_type', 'App\Video');
}
}