Trying to fetch persons table based on the result of the polymorphic relations. What is the professional standard way on doing this? Thank you very much!
Insertable model
public function insertables() {
return $this->morphMany(Insertable::class, 'insertable');
}
Person model
public function insertable () {
return $this->morphTo();
}
$people = Person::find($id)->insertables;
$peopleIds = $people->pluck('person_id');
return response()->json(Person::whereIn('id', $peopleIds)->get());