How to make if statement using implode . if uncheck the database make it null .
databasetable:
$table->string('ads')->nullable();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I want to store in database using checkbox, but when it is left unchecked. it gives error:
implode(): Argument #1 ($pieces) must be of type array, string given
StoreController:
$applications->ads = implode(',', $request->ads);
As mentioned by jlrdw, you can check if the request passed the checkbox or not, you can use $request->has('cb_name')
Please or to participate in this conversation.