Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allows to get table and primary key name out of the model #1196

Merged
merged 1 commit into from
Sep 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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