I have a function to update record.
// POST BR(E)AD
public function update(Request $request, $id)
{
$slug = $this->getSlug($request);
$dataType = Voyager::model('DataType')->where('slug', '=', $slug)->first();
// Check permission
Voyager::canOrFail('edit_'.$dataType->name);
//Validate fields with ajax
$val = $this->validateBread($request->all(), $dataType->editRows);
if ($val->fails()) {
return response()->json(['errors' => $val->messages()]);
}
if (!$request->ajax()) {
$data = call_user_func([$dataType->model_name, 'findOrFail'], $id);
$this->insertUpdateData($request, $slug, $dataType->editRows, $data);
return redirect()
->route("voyager.{$dataType->slug}.edit", ['id' => $id])
->with([
'message' => "Successfully Updated {$dataType->display_name_singular}",
'alert-type' => 'success',
]);
}
}
All form is filled with data. A fields images
contain multiple images. It's save with array.
I debug:
When the user input is filled, all value will post to the variable val
. You can see at field images
is array have one item.
Variable data
will keep all values and save to a database.
I don't know data['images' = null
.
You can see at:
So, all field is updated successfully except field images
.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2sU3Qle
via IFTTT
Aucun commentaire:
Enregistrer un commentaire