All actions requested by DataTables Editor are being submitted via POST
ajax request.
This means, that we need to create a post
request route that will handle all the actions we need.
This doc assumes that you are already knowlegeable of DataTables Editor library.
You can create your editor using artisan command.
php artisan datatables:editor Users
See editor model docs for ref:
See editor rules docs for ref:
use App\DataTables\UsersDataTablesEditor;
Route::post('editor', function(UsersDataTablesEditor $editor) {
return $editor->process(request());
});
Since actions are being sent via post
, we need to make sure that we setup csrf-token.
Just add the snippets below before your scripts to avoid csrf errors:
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
You can use DataTables Editor Generator to help you speed-up the process. Once generated, copy the necessary scripts and html on your blade template.