当我尝试将字段或记录手动添加到表中时,我从该ajax函数获得内部服务器错误响应
我是laraadmin的新手,所以我不太了解文件结构
索引视图中的代码:
<script>
$(function () {
$("#example1").DataTable({
processing: true,
serverSide: true,
ajax: "{{ url(config('laraadmin.adminRoute') . '/event_rule_car_dt_ajax') }}",
language: {
lengthMenu: "_MENU_",
search: "_INPUT_",
searchPlaceholder: "Search"
},
@if($show_actions)
columnDefs: [ { orderable: false, targets: [-1] }],
@endif
});
$("#event_rule_car-add-form").validate({
});
});
</script>
以及控制器中的功能:
public function dtajax()
{
$values = DB::table('event_rule_cars')->select($this->listing_cols)->whereNull('deleted_at');
$out = Datatables::of($values)->make();
$data = $out->getData();
$fields_popup = ModuleFields::getModuleFields('Event_rule_cars');
for($i=0; $i < count($data->data); $i++) {
for ($j=0; $j < count($this->listing_cols); $j++) {
$col = $this->listing_cols[$j];
if($fields_popup[$col] != null && starts_with($fields_popup[$col]->popup_vals, "@")) {
$data->data[$i][$j] = ModuleFields::getFieldValue($fields_popup[$col], $data->data[$i][$j]);
}
if($col == $this->view_col) {
$data->data[$i][$j] = '<a href="'.url(config('laraadmin.adminRoute') . '/event_rule_cars/'.$data->data[$i][0]).'">'.$data->data[$i][$j].'</a>';
}
// else if($col == "author") {
// $data->data[$i][$j];
// }
}
if($this->show_action) {
$output = '';
if(Module::hasAccess("Event_rule_cars", "edit")) {
$output .= '<a href="'.url(config('laraadmin.adminRoute') . '/event_rule_cars/'.$data->data[$i][0].'/edit').'" class="btn btn-warning btn-xs" style="display:inline;padding:2px 5px 3px 5px;"><i class="fa fa-edit"></i></a>';
}
if(Module::hasAccess("Event_rule_cars", "delete")) {
$output .= Form::open(['route' => [config('laraadmin.adminRoute') . '.event_rule_cars.destroy', $data->data[$i][0]], 'method' => 'delete', 'style'=>'display:inline']);
$output .= ' <button class="btn btn-danger btn-xs" type="submit"><i class="fa fa-times"></i></button>';
$output .= Form::close();
}
$data->data[$i][] = (string)$output;
}
}
$out->setData($data);
return $out;
}