File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 33namespace  FiveamCode \LaravelNotionApi \Endpoints ;
44
55use  FiveamCode \LaravelNotionApi \Entities \Blocks \Block ;
6+ use  FiveamCode \LaravelNotionApi \Entities \Collections \PageCollection ;
67use  FiveamCode \LaravelNotionApi \Entities \Database ;
78use  FiveamCode \LaravelNotionApi \Entities \NotionParent ;
89use  FiveamCode \LaravelNotionApi \Entities \Page ;
10+ use  FiveamCode \LaravelNotionApi \Entities \Properties \Relation ;
911use  FiveamCode \LaravelNotionApi \Entities \User ;
1012use  FiveamCode \LaravelNotionApi \Exceptions \HandlingException ;
1113use  FiveamCode \LaravelNotionApi \Exceptions \NotionException ;
1214use  FiveamCode \LaravelNotionApi \Notion ;
15+ use  Illuminate \Support \Collection ;
1316
1417/** 
1518 * Class Resolve. 
@@ -63,4 +66,29 @@ public function parent(NotionParent $parent): Page|Database|Block
6366                throw  new  HandlingException ('Unknown parent type while resolving the notion parent ' );
6467        }
6568    }
69+ 
70+     /** 
71+      * @param  Relation  $relation 
72+      * @return Collection<Page> 
73+      * 
74+      * @throws HandlingException 
75+      * @throws NotionException 
76+      */ 
77+     public  function  relations (Relation $ relationbool  $ onlyTitlesfalse ): Collection 
78+     {
79+         $ pagescollect ();
80+         $ relationIds$ relationgetRelation ()->map (function  ($ o
81+             return  $ o'id ' ];
82+         });
83+ 
84+         foreach  ($ relationIdsas  $ relationId
85+             if  ($ onlyTitles
86+                 $ pagesadd ($ this notion ->pages ()->find ($ relationIdgetTitle ());
87+             } else  {
88+                 $ pagesadd ($ this notion ->pages ()->find ($ relationId
89+             }
90+         }
91+ 
92+         return  $ pages
93+     }
6694}
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments