1

尝试根据多态关系的结果获取人员表。这样做的专业标准方法是什么?非常感谢!

可插入模型

public function insertables() {
return $this->morphMany(Insertable::class, 'insertable');
}

人物模型

public function insertable () {
return $this->morphTo();    
}

$people = Person::find($id)->insertables;
$peopleIds = $people->pluck('person_id');
return response()->json(Person::whereIn('id', $peopleIds)->get());
4

0 回答 0