Привет, у меня есть этот флажок выбора, это время, когда я проверяю, все ли значения проходят через него! Теперь моя проблема в том, что когда я сохраняю в базе данных, сохраняется только одно значение. это мой клинок
клинок. php
'<div class="col-md-2">\n' +
'<div class="form-group">\n' +
'<div class="custom-control custom-checkbox my-4 mr-sm-2">\n' +
'<?php $studying = json_decode(auth()->user()->studying, true);?>\n' +
'<input {{ isset($studying[$key]) && $studying[$key] ? 'checked' : ''}} type="checkbox" value="1" class="custom-control-input" name="studying" id="studying">\n' +
'<label class="custom-control-label" for="studying">studying</label>\n' +
'</div>\n' +
'</div>\n' +
'</div>\n' +
'<div class="col-md-2">\n' +
'<div class="form-group">\n' +
'<div class="custom-control custom-checkbox my-4 mr-sm-2">\n' +
'<?php $studying = json_decode(auth()->user()->studying, true);?>\n' +
'<input {{ isset($studying[$key]) && $studying[$key] ? 'checked' : ''}} type="checkbox" value="1" class="custom-control-input" name="studying" id="studying">\n' +
'<label class="custom-control-label" for="studying">studying</label>\n' +
'</div>\n' +
'</div>\n' +
'</div>\n' +
Контроллер
$sundays = $request->input('studying');
$sundaysArray = array();
foreach($sundays as $sunday){
$sundaysArray[] = $sunday;
}
$user->studying = json_encode($sundaysArray);
$user->save();
Я хочу сохранить как ["on","off"]
, но он сохраняет ["on"]