0π
β
No need to use vue.js. Just use simple jQuery code as below. Hope itβs
help.
jQuery Code:
Add event on save button On Click
onclick="saveProfile(INPUT ID HERE, RECORD ID)"
Add jquery code in your footer or view file
function saveProfile(id, inputid) {
var value = $(inputid).val();
$.ajax({
headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
url: "{{URL::to('admin/updateProfile')}}",
data:{'id' : id,'value' : value,'inputid':inputid},
method:'POST',
success: function( resp ) {
alert('update');
},
error: function( req, status, err ) {
console.log( 'something went wrong', status, err );
}
});
}
Controller code
public function updateProfile(REQUEST $request){
$id = $request->id;
$value = $request->value;
$inputid = $request->inputid;
//for examaple - Input textbox id is : pemail-form
if($inputid == 'pemail-form'){
DB::table('table_name')->where('id', $id)->update(['email' => $value]);
}
if($inputid == 'fullname-form'){
DB::table('table_name')->where('id', $id)->update(['fullname' => $value]);
}
}
Source:stackexchange.com