Skip to content

Commit

Permalink
Update Model.php
Browse files Browse the repository at this point in the history
adding additional if for __get method to make easier achieve sth like this:
$row->{$model->primaryKey}
  • Loading branch information
nowackipawel authored Sep 3, 2018
1 parent 368d305 commit e2c9c2a
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 e2c9c2a

Please sign in to comment.