【发布时间】:2018-12-19 18:19:26
【问题描述】:
所以我试图在我创建的数组中访问几对 key->values 的值并将其传递给名为 config 的视图,我想像这样访问它们:{{ $config->web_name['value'] }} 或 @987654323 @ 但两者都返回错误。
这就是我将数据传递给视图的方式:
public function inicio()
{
$pageInfo =
[
'page_title' => 'Inicio',
'menu_active' => 'Inicio',
'submenu_active' => '',
];
$globals = Globals::all();
$web_name = $globals->where('name', 'Nombre del restaurante')->first();
$web_description = $globals->where('name', 'Descripcion en google del restaurante')->first();
$restaurant_bio = $globals->where('name', 'Biografia del restaurante')->first();
$booking_phone = $globals->where('name', 'Télefono de reserva')->first();
$client_mail = $globals->where('name', 'Email de contacto')->first();
$full_address = $globals->where('name', 'Dirección del restaurante')->first();
$city_zip_address = $globals->where('name', 'Código postal y ciudad')->first();
$config = compact('web_name', 'web_description');
$sliders = Slider::all();
return view('inicio.index', compact('pageInfo', 'config', 'sliders', 'web_name'));
}
【问题讨论】:
-
粘贴错误详情
-
试图获取非对象的属性“web_name”(查看:C:\xampp\htdocs\Restaurante1\resources\views\inicio\index.blade.php)
-
你的 $config 不是对象。是数组。稍微阅读一下错误,它解释得很好。
标签: javascript php arrays laravel