Skip to content

Commit

Permalink
Merge pull request #1196 from nowackipawel/patch-6
Browse files Browse the repository at this point in the history
allows to get table and primary key name out of the model
  • Loading branch information
lonnieezell authored Sep 4, 2018
2 parents 368d305 + e2c9c2a commit 72e77c6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions system/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -1376,15 +1376,19 @@ protected function trigger(string $event, array $data)
//--------------------------------------------------------------------

/**
* Provides/instantiates the builder/db connection.
* Provides/instantiates the builder/db connection and model's table/primary key names and return type.
*
* @param string $name
*
* @return null
*/
public function __get(string $name)
{
if (isset($this->db->$name))
if(in_array($name, ['primaryKey', 'table', 'returnType']))
{
return $this->{$name};
}
elseif (isset($this->db->$name))
{
return $this->db->$name;
}
Expand Down

0 comments on commit 72e77c6

Please sign in to comment.