Reputation: 237
I've been stored my checkbox value into DB using this code
$request->merge([
'revisi_dokumen' => implode(',', (array) $request->get('revisi_dokumen'))
]);
But now i can't get it back when i try to edit(in editpage.blade), i want the checkbox is checked if it's value same as value in DB, how do do that guys ? please kindly help me solve
Upvotes: 1
Views: 553
Reputation: 13259
You used implode()
to store, use explode()
to retrieve.
$values = explode(",", $model->revisi_dokumen);
In your view you check if the checkbox value is in the array
<input type="checkbox" name="revisi_dokumen[]" value="1" {{ in_array('1', $values) ? 'checked' : '' }}>One
Upvotes: 1