Laravel & LaravelCollective 第一个参数应该是字符串或整数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45988933/
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:34:53  来源:igfitidea点击:

Laravel & LaravelCollective The first argument should be either a string or an integer

laravellaravelcollective

提问by qqmydarling

Im trying to create DELETE button in my Laravel CRUD app. and have an error:

我试图在我的 Laravel CRUD 应用程序中创建 DELETE 按钮。并有一个错误:

(2/2) ErrorException array_key_exists(): The first argument should be either a string or an integer

(2/2) ErrorException array_key_exists():第一个参数应该是字符串或整数

My view:

我的看法:

{{!!Form::open(['action' => ['CompanyController@update', $company->id], 'method' => 'PUT'])!!}}
                            {{Form::input('Delete',['class'=>'btn btn-danger'])}}
                        {{!!Form::close()!!}}

I'm using Laravel Collective documentation and it says I can use:

我正在使用 Laravel Collective 文档,它说我可以使用:

 Form::open(['action' => ['Controller@method', $user]])

But whats wrong with my code?

但是我的代码有什么问题吗?

采纳答案by Arthur Samarcos

You must provide the key. Collective won't try to guess the key name, as we are used to on Laravel.

您必须提供密钥。Collective 不会尝试猜测键名,就像我们在 Laravel 上习惯的那样。

Form::open(['action' => ['Controller@method', $user->id]])

The piece of code above shows how to provide the key: $user->id

上面的一段代码展示了如何提供密钥:$user->id