File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
src/Filament/RelationManagers Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -326,11 +326,23 @@ public static function getPluralModelLabel(): string
326326
327327 protected function getSchemaOptions (): array
328328 {
329- $ options = \Backstage \Fields \Models \Schema::where ('model_key ' , $ this ->ownerRecord ->getKey ())
329+ $ schemas = \Backstage \Fields \Models \Schema::where ('model_key ' , $ this ->ownerRecord ->getKey ())
330330 ->where ('model_type ' , get_class ($ this ->ownerRecord ))
331331 ->orderBy ('position ' )
332- ->pluck ('name ' , 'ulid ' )
333- ->toArray ();
332+ ->get ();
333+
334+ return $ this ->buildSchemaTree ($ schemas );
335+ }
336+
337+ protected function buildSchemaTree ($ schemas , $ parentId = null , $ depth = 0 ): array
338+ {
339+ $ options = [];
340+ $ children = $ schemas ->where ('parent_ulid ' , $ parentId );
341+
342+ foreach ($ children as $ schema ) {
343+ $ options [$ schema ->ulid ] = str_repeat ('— ' , $ depth ) . $ schema ->name ;
344+ $ options = $ options + $ this ->buildSchemaTree ($ schemas , $ schema ->ulid , $ depth + 1 );
345+ }
334346
335347 return $ options ;
336348 }
You can’t perform that action at this time.
0 commit comments