Skip to content

Commit

Permalink
Merge pull request #2 from TebexOllie/static-table-fields
Browse files Browse the repository at this point in the history
Made tableFields static
  • Loading branch information
liam-wiltshire committed Apr 7, 2021
2 parents aa1a895 + 060272f commit ff4157b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Concerns/HasMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
trait HasMeta
{

protected $tableFields;
protected static $tableFields;

/**
* Get all the fields for this models DB table
Expand All @@ -16,15 +16,15 @@ trait HasMeta
*/
public function getTableFields(): array
{
if (!$this->tableFields) {
if (!self::$tableFields) {
$connection = $this->getConnection();

$fields = $connection->getSchemaBuilder()->getColumnListing($this->getTable());

$this->tableFields = array_flip($fields);
self::$tableFields = array_flip($fields);
}

return $this->tableFields;
return self::$tableFields;
}

/**
Expand Down

0 comments on commit ff4157b

Please sign in to comment.