[英]How can I use whereHas on a relation to the same table with Eloquent Query Builder?
[英]How can i use whereHas to get data from related mophic table in eloquent
我正在使用 eloquent,任何幫助!
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);
});
希望這可以幫到你。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.