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

ploger's avatar

how to fix Argument #1 ($value) must be of type int, string given in laravel

hello guy i tried to insert multiple values into one column in the table i use a checkbox i use enums with foreach to get data of an enum called days also I use simple checkbox but when I try to do that and I want to save data I have this problem of App\Enums\days::from(): Argument #1 ($value) must be of type int, string given ====> This is column on db $table->string('days'); ===> controller function $validatedData = $request->validated(); $days = implode(",", $validatedData['days']); $userId = Auth::id(); $data = array_merge($validatedData, [ 'createdBy' => $userId, 'days' => $days, ]); supplier::create($data); also i use name="days[]" on view

0 likes
2 replies
ploger's avatar

@tykus I fixed the problem my friend tanks a lot and about the code I use a free plan and I am new on Laracasts the problem I found is I named the enum like days and in the table I use the same name but I do not define the enums in this column this is the problem when I define the enum the problem is fixed and Also when I want to save the data I use this json_encode($days) tank a lot, my friend

Please or to participate in this conversation.