Skip to content

Commit d0a04fc

Browse files
author
David Nahodyl
committed
Added support for $guarded
1 parent 28df4c0 commit d0a04fc

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src/Database/Schema/FMBuilder.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
}

src/Services/FileMakerConnection.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use BlueFeather\EloquentFileMaker\Database\Eloquent\FMEloquentBuilder;
88
use BlueFeather\EloquentFileMaker\Database\Query\FMBaseBuilder;
99
use BlueFeather\EloquentFileMaker\Database\Query\Grammars\FMGrammar;
10+
use BlueFeather\EloquentFileMaker\Database\Schema\FMBuilder;
1011
use BlueFeather\EloquentFileMaker\Exceptions\FileMakerDataApiException;
1112
use GuzzleHttp\Exception\ConnectException;
1213
use 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
}

0 commit comments

Comments
 (0)