where('tenant_id', $item->tenant_id) ->where('source_type', 'inventory_item') ->where('source_id', $item->external_id) ->orderByDesc('created_at'); if ($relationshipType !== null) { $query->where('relationship_type', $relationshipType); } return $query->limit($limit)->get(); } public function getInboundEdges(InventoryItem $item, ?string $relationshipType = null, int $limit = 50): EloquentCollection { $query = InventoryLink::query() ->where('tenant_id', $item->tenant_id) ->where('target_type', 'inventory_item') ->where('target_id', $item->external_id) ->orderByDesc('created_at'); if ($relationshipType !== null) { $query->where('relationship_type', $relationshipType); } return $query->limit($limit)->get(); } }