【问题标题】:octobercms showing relationship dataoctobercms 显示关系数据
【发布时间】:2017-09-19 16:32:33
【问题描述】:

我是 octobercms 的新手。我在我的树枝模板页面上显示关系数据时遇到问题。

在我的页面上,我正在获取如下记录:

$this['education'] = Education::where('user_id', '=', $logged_in_user->id)->with('transcript')->get();

在我的部分中,我可以获得如下记录:

[  
  {  
    "id":56,
    "user_id":6,
    "created_at":"2017-08-24 07:56:09",
    "updated_at":"2017-08-25 16:39:17",
    "school_name":"UCT",
    "degree_name":"Finance",
    "majors":"test2",
    "achievements":"",
    "transcript":{  
      "id":20,
      "disk_name":"59a03695e24c3772338596.png",
      "file_name":"step1.png",
      "file_size":68042,
      "content_type":"image\/png",
      "title":null,
      "description":null,
      "field":"transcript",
      "sort_order":20,
      "created_at":"2017-08-25 16:39:17",
      "updated_at":"2017-08-25 16:39:17",
      "path":"http:\/\/talentlatch.dev\/storage\/app\/uploads\/public\/59a\/036\/95e\/59a03695e24c3772338596.png",
      "extension":"png"
    },
    "start_date":"2015-01-01 00:00:00",
    "end_date":"2017-08-01 00:00:00",
    "is_fulltime":1
  }
]

但是当我试图在页面上显示文件名属性时,我无法得到它。我尝试了以下解决方案:

{{ education[0].transcript.file_name }}

{{ education[0]['transcript'].file_name }}

提前谢谢.....

【问题讨论】:

  • 你试过像{% foreach item in education %} item.transcript.filename {% endfor %} 这样的foreach吗

标签: octobercms


【解决方案1】:

教育变量是Collection,所以试试

{{ education.first().id }}

如果你会成功,那就试试

{{ education.first().transcript.file_name }}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-13
    • 1970-01-01
    • 2020-11-09
    • 2019-08-16
    • 2016-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多