Apply Dynamic Where condition on Relationship Eloquent ORM
Copy Below Code
View As A Text File
Show Text Only
Show API
Edit Code
$permissions = ModelName::where('parent_id', 0)->
with(['children' => function ($query) use($allowModules) {
$query->whereIn('module_id',$allowModules);
}])->
orderBy('sort_order', 'ASC')->get();