Search code examples
laravellaravelcollective

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


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

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

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:

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

But whats wrong with my code?


Solution

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

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

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