For example, I have a "Users" model (table) like this (simplified):
class Users extends Model
{
public $id;
public $name;
}
and the "Posts" model:
class Posts extends Model
{
public $id;
public $title;
public $description;
public $uid; // "uid" contains an id from the "Users" table.
// This is the my variant and I don't understand how can I get this, help))
public function initialize()
{
$this->hasOne('uid', 'Users', 'id');
}
}
I want to connect this tables and get the name from Users by uid from Posts (id == uid). How can I do it and get from controller?