【问题标题】:OctoberCMS (Laravel) Field select statementOctoberCMS (Laravel) 字段选择语句
【发布时间】:2021-03-26 22:10:32
【问题描述】:

我需要像以下格式一样添加到我的关系字符串中:Name Surname(帖子)和我需要从另一个表中获取的帖子(在这个关系中,我只有 post_id)。如何使用fields.yaml 文件获取post.title

    professors:
        label: Преподаватель
        descriptionFrom: description
        span: auto
        required: 1
        type: relation
        select: concat(name, ' ', surname, ' ', post_id) // Already working
        select: SELECT title FROM titamik_cio_post WHERE id=post_id as post concat(name, ' ', surname, ' ', post) // ??????

【问题讨论】:

    标签: laravel octobercms


    【解决方案1】:

    我认为最简洁的方法是在相关模型中定义范围。

        professors:
            label: Преподаватель
            nameùfrom: title
            descriptionFrom: description
            span: auto
            required: 1
            type: relation
            scope: yourScopeName
    

    您需要根据文档 (https://octobercms.com/docs/database/model#query-scopes) 在相关表单模型类中定义您的范围。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-27
      • 1970-01-01
      • 2015-08-19
      • 2014-11-21
      • 1970-01-01
      相关资源
      最近更新 更多