我在用雄辩,有什么帮助吗?
return House::whereHas('extendable', function($extendUnits) use($projectdeciphered){
$extendUnits->where('project_id', $projectdeciphered);
});
你可以使用如下所示的whereHasMorph:https://laravel.com/docs/9.x/eloquent-relationships querying-morph-to-relationships
House::whereHasMorph('extendable', [Extend::class, Unit::class], function($extendUnits) use($projectDeciphered){
$extendUnits->where('project_id', $projectDeciphered);
});
希望这对你有帮助。