我用 Builder 创建了一个 OctoberCMS plugin .

我只需要 to pick some data from Rainlab.User plugin tables and show as columns in my backend.

我只需要列出所有管理员用户,并在我的插件后端表列表中为每个用户分配一些新值 .

所以我需要列出

ID | USERNAME | EMAIL | MYCOLUMN1 | MYCOLUMN2 | MYCOLUMNn

但我无法弄清楚如何从RainLab用户表中获取用户名和电子邮件 .

我试着扩展我的模型

class MyPluginClass extends Model
{

...

public $hasOne  = [
      'my_relation'=>'Rainlab\User\Models\User',
      'key' => 'email',
      'otherKey' => 'email'
    ];

...

并在我的columns.yaml中使用此代码:

columns:
    ...
    email:
        label: EMAIL
        type: text
        searchable: true
        sortable: true
        relation: my_relation
        select: email

但我得到这个错误:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.myplugin_id' in 'where clause' (SQL: select `me_mytable_`.*, (select id from `users` where `me_mytable_`.`id` = `users`.`myplugin_id`) as `email` from `me_mytable_` where `me_mytable_`.`deleted_at` is null order by `id` desc limit 20 offset 0)

任何帮助赞赏 .