首页 文章

octobercms显示关系数据

提问于
浏览
1

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

    教育变量是Collection,所以试试吧

    {{ education.first().id }}

    如果你会成功,那就试试吧

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

相关问题