File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed
Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace BlueFeather \EloquentFileMaker \Database \Schema ;
4+
5+ class FMBuilder extends \Illuminate \Database \Schema \Builder
6+ {
7+ /**
8+ * Get the column listing for a given table.
9+ *
10+ * @param string $table
11+ * @return array
12+ */
13+ public function getColumnListing ($ table )
14+ {
15+ $ layoutMetaData = $ this ->connection ->getLayoutMetadata ($ table );
16+ $ fieldMetaData = $ layoutMetaData ['fieldMetaData ' ];
17+ $ columns = array_column ($ fieldMetaData , 'name ' );
18+
19+ return $ columns ;
20+ }
21+
22+ }
Original file line number Diff line number Diff line change 77use BlueFeather \EloquentFileMaker \Database \Eloquent \FMEloquentBuilder ;
88use BlueFeather \EloquentFileMaker \Database \Query \FMBaseBuilder ;
99use BlueFeather \EloquentFileMaker \Database \Query \Grammars \FMGrammar ;
10+ use BlueFeather \EloquentFileMaker \Database \Schema \FMBuilder ;
1011use BlueFeather \EloquentFileMaker \Exceptions \FileMakerDataApiException ;
1112use GuzzleHttp \Exception \ConnectException ;
1213use GuzzleHttp \Exception \RequestException ;
@@ -100,8 +101,12 @@ protected function getRecordUrl()
100101 return $ this ->getLayoutUrl () . '/records/ ' ;
101102 }
102103
103- protected function getLayoutUrl ()
104+ protected function getLayoutUrl ($ layout = null )
104105 {
106+ // Set the connection layout as the layout parameter, otherwise get the layout from the connection
107+ if ($ layout ){
108+ $ this ->setLayout ($ layout );
109+ }
105110 return $ this ->getDatabaseUrl () . '/layouts/ ' . $ this ->getLayout ();
106111 }
107112
@@ -637,4 +642,16 @@ protected function getDefaultQueryGrammar()
637642 {
638643 return new FMGrammar ();
639644 }
645+
646+ public function getLayoutMetadata ($ layout = null ){
647+ $ response = $ this ->makeRequest ('get ' , $ this ->getLayoutUrl ($ layout ));
648+ return $ response ['response ' ];
649+ }
650+
651+ public function getSchemaBuilder ()
652+ {
653+ parent ::getSchemaBuilder ();
654+
655+ return new FMBuilder ($ this );
656+ }
640657}
You can’t perform that action at this time.
0 commit comments