Laravel 中不支持的操作数类型
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26242351/
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 10:15:14 来源:igfitidea点击:
Unsupported operand types in laravel
提问by Chibi
When I click on a menu to edit I get this error
当我单击菜单进行编辑时,出现此错误
Unsupported operand types
不支持的操作数类型
and the line that it shows is
它显示的行是
{{ Form::select('submenu_id', array('default' => 'Please Select') + $submenu_options ) }}
and that is in my edit.blade.php
那是在我的 edit.blade.php
回答by sanu
In Laravel 5.1 i solved it by doing
在 Laravel 5.1 中我解决了它
$categories = [''=>''] + Category::lists('name', 'id')->toArray();
return view('products.create', compact('categories'));
Or
或者
$categories = [''=>''] + Category::lists('name', 'id')->all();
return view('products.create', compact('categories'));
回答by Nilesh Chourasia
In controller you have not added submenu options, because of that reason it is showing this error :
在控制器中,您尚未添加子菜单选项,因此它显示此错误:
return View::make('modulename.form')
->with('editMode', true)
->with('submenu_options','')
->with('customFields', $this->customField->getByTable('tablename'));