Laravel Blade 中的回声值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46830111/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 16:50:06  来源:igfitidea点击:

Echo value in Laravel Blade

phplaravelblade

提问by user2262502

How can I get the value 'name' under 'rekenplichtige' in my Blade template? If I do this: {{ $vestiging->rekenplichtige->name }}I get the following error: ErrorException Trying to get property of non-object

如何在我的 Blade 模板中的“rekenplichtige”下获取值“name”?如果我这样做:{{ $vestiging->rekenplichtige->name }}我收到以下错误:ErrorException Trying to get property of non-object

That syntax is working to get the 'naam' under 'gemeente'. I have no idea about what's going wrong.

该语法正在努力获得“gemeente”下的“naam”。我不知道出了什么问题。

enter image description here

在此处输入图片说明

回答by Gvep

 {{ $vestiging->rekenplichtige}} 

since "name" inside an array, you should array notation to get name. Like below

由于数组中的“名称”,您应该使用数组符号来获取名称。像下面

{{ $vestiging->rekenplichtige['name'] }}

回答by user2262502

{{ $vestiging->rekenplichtige()->first()->name }}

This is working.

这是有效的。