Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

COUPDEGRACES's avatar

Argument 1 passed to Illuminate\Database\Eloquent\Builder::update() must be of the type array,

I hava error when im edit my TagsController.php , and error is

Argument 1 passed to Illuminate\Database\Eloquent\Builder::update() must be of the type array, string given, called in /web/app/Http/Controllers/TagsController.php on line 89

my controller is

 $this->validate($request, [
            'name' => 'required|max:20|min:3'
        ]);
            $tags_data = [
                'name' => $request->name,
                'slug' => Str::slug($request->name)
            ];
            Tags::whereId($id)->update('tags_data');

            return rediect()->route('tag.index')->with('Berhasil','Tag Sudah berhasil diupdate');

line 89 is

Tags::whereId($id)->update('tags_data');
0 likes
1 reply
Talinon's avatar

@hendrasaputra2323

This is what you need.. you need to pass in a variable, instead you are passing in the string of the variable's name.

 Tags::whereId($id)->update($tags_data);

Please or to participate in this conversation.