octobercms显示关系数据

时间:2017-08-28 05:43:03

标签: octobercms

我是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 }}

提前致谢.....

1 个答案:

答案 0 :(得分:0)

教育变量是Collection,请尝试

{{ education.first().id }}

如果您成功,请尝试

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