【发布时间】:2019-07-09 18:02:13
【问题描述】:
我正在为我的视图编辑器使用一个数组,当我尝试查看页面 Cannot use object of type Closure as array 时它会引发此错误。
我尝试使用 eloquent 来代替变量,但最终没有奏效,因为这不是我使用它们的方式应该如何构建的。我还尝试在 $view->with()variable 中创建一个函数。
public function compose(View $view)
{
$view->with('configurable', function() {
$configurables = Cache::rememberForever('configurables', function() {
return Configurables::all();
});
$configurable = [];
foreach($configurables as $key) {
$configurable[$key->slug] = [
'value' => $key->value
];
}
return $configurable;
});
}
【问题讨论】:
-
你能显示完整的错误和发生错误的行吗?