我正在开发一个项目,并使用bootstrap模式为我的数据库中的记录打开一个编辑表单。编辑完成后,我可以使用ajax post将数据提交给我的控制器"更新"。使用$ data = Input :: all(),我可以获得从提交中发送的内容,并且使用$ test = $ data [' test'],我能够获得个别领域。但是,当我从我的数据库中获取特定记录(可以使用print_r($ record)确认此工作)并进行更改时,在使用$ record-> save()之后,我收到错误500(内部服务器错误)。我无法弄清问题是什么。任何帮助将不胜感激。提前完成。
**Code below:**
***javascript:***
$('#editForm').on('submit', function(e){
$.ajaxSetup({
headers: { 'X-CSRF-Token' : $('meta[name="_token"]').attr('content') }
});
e.preventDefault();
var $form = $('#editForm');
var projectnr = $form.find('[name="project"]').val();
var projectpart = $form.find('[name="projectpart"]').val();
var termnr = $form.find('[name="termnr"]').val();
var status= $form.find('[name="status"]').val();
var amount= $form.find('[name="amount"]').val();
var comment= $form.find('[name="comment"]').val();
$.ajax({
url: 'http://kpakpa.com/prefactuur/' + projectnr + '/' + termijnnr + '/' + projectdeel + '/' + 'update',
type: "POST",
cache: false,
data: {project: projectnr, projectpart: projectpart, termnr: termnr, status: status, amount: amount, comment: commment},
success: function(data){
console.log(data);
}
});
});
**Controller**
public function update(Request $request){
$data = Input::all();
$project = $data['project'];
$projectpart = $data['projectpart'];
$termnr = $data['termnr'];
$project= $this->project->where(array('project' => $project, 'projectpart' => $projectpart, 'termnr' => $termnr))->first();
//What i want to change
$project->status = $data['status'];
$project->amount = $data['amount'];
$prefac->comment = $data['comment'];
$project->save