I am getting a strange error which I am not sure if Laravel related. I have created a generic Document Model to store data for different types of Documents. It works perfectly for everything apart from one document. One of my documents have a load of checkboxes which take the following form
<div class="col-md-6 checkbox checkbox-danger">
{!! Form::checkbox('testingOptions[]', 'Style vs. product based', null, ['class' => 'styled', 'id' => 'checkbox1']) !!}
<label for="checkbox1">
Style vs. product based
</label>
</div>
So the selected options are stored in testingOptions[]. In my controller, if I output the inputted data I get something like this
array:10 [▼
"_token" => "XGz0x2nivwEuHmYziosFzExGjwWY41GZDdUxSaJi"
"description" => ""
"objective" => "sfrgdf"
"audience" => "gdfgd"
"segmentation" => ""
"testingOptions" => array:2 [▼
0 => "Style vs. product based"
1 => "Use contest or prize draw"
]
"successMeasure" => ""
"deliverables" => ""
"keyDates" => ""
"filePath" => array:1 [▶]
]
Now because testingOptions is an array, I need to treat it differently when saving. My generic safe code is like so
$inputs = $request->all();
foreach ($inputs as $key => $value) {
if($key !== '_token' && $key !== 'filePath' && $key !== '_method' && $key !== 'testingOptions') {
$documentData = new DocumentData();
$documentData->documentId = $document->id;
$documentData->key = $key;
$documentData->value = $value;
$documentData->save();
}
}
With the above, if I try to safe the Document, I get an Windows error saying CLI has stopped working, and this stops my php server. The issue comes down to the if statement above, more specifically checking for testingOptions. If I remove this part from the if statement, I do not get the CLI error.
Has anyone seen something like this before?
Thanks
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1SMnkh9
via IFTTT
Aucun commentaire:
Enregistrer un commentaire