doubi1713 2014-07-24 08:19
浏览 78
已采纳

我将如何在generator.yml文件中创建JOIN?

I have a generator.yml file in the backend folder, the config in the generator file is:

generator:

config:
  actions: ~
  list:
    title: Send Email
    display: [subject, Body, email_Type_id, user_id]

  filter:
    display: [id, subject, Body, email, user_id]

The email_id and user_id was foreign key in the message table and primary key in (email table, user table), and it show in the fields the id but i want to let it show the user of the id that related to the message so i need to JOIN! how i will make it?

subject->Hello, Body->Hi iam.., Email_Type_id->1, User_id->8

In the email_id and user_id i want to show the user_name with the id 5 and in the email_type_id I want to show the type with id 1

  • 写回答

1条回答 默认 最新

  • doubi1818 2014-07-24 18:56
    关注

    The only way to do it is add the join in your model in a new getter and reference the getter in your generator config.

    public function getUser_name()
    {
        return $this->User->getName();
    }
    
    public function getEmail_type_name()
    {
        return $this->Email_type->getName();
    }
    

    Then in your generator:

    display: [subject, body, email_type_name, user_name]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog