Just post the data and do an update.
https://laravel.com/docs/5.4/eloquent#updates
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am inserting records in laravel using the following function in the controller file.
function postSave( Request $request)
{
$rules = $this->validateForm();
$validator = Validator::make($request->all(), $rules);
if ($validator->passes()) {
$data = $this->validatePost( $request );
$id = $this->model->insertRow($data , $request->input('Id'));
$this->detailviewsave( $this->modelview , $request->all() ,$this->info['config']['subform'] , $id) ;
return Redirect::to($return)->with('messagetext',\Lang::get('core.note_success'))->with('msgstatus','success');
}
}
We have a free tour that we offer. I have a checkbox in the form.blade file.
<label for="Tour Name" class=" control-label col-md-4 text-left"> Tour Name <span class="asterix"> * </span></label>
<select name='BookingID' rows='5' id='BookingID' class='select2 ' required >option value="1"> Expect the Unexpected</option><option value="13">WOW! Wildlife Experience </option><option value="14">PM Cruise</option><option value="15">Sundown</option><option value="16">Wildnight</option><option value="17">On The Beach</option></select>
<label for="TSunsetNeeded" class=" control-label col-md-4 text-left"> Free Sunset </label>
<input type='checkbox' name='tSunsetNeeded[]' value ='1'
class=' minimal-red' @if(in_array('1',$tSunsetNeeded))checked @endif />
So, If this checkbox is clicked (if value 1 is sent) I want to re-insert the same data again into mysql with only one difference - the field BookingID needs to be recorded in mysql with ID 17 (which is our free tour ID). So the database should look like this:
Id BookingID GuestName Adults Children
---------------------------------------------
1001 13 Anna Becks 2 1
1002 17 Anna Becks 2 1
May be this is a dump question but I don't know how to manipulate the data and re-insert it into mysql. I would appreciate any suggestion / example.
Please or to participate in this conversation.