Answer the question
In order to leave comments, you need to log in
How to transfer data to the database when sorting through sortable?
Hello everyone, Happy New Year and Merry Christmas!
I'm doing sorting using jquery-ui - sortable
Drag and drop implemented - https://codepen.io/pavel-lipatkin/pen/OJPxBbK
but how to take the values from the transferred blocks and write them to the database?
Writing to the database directly via AJAX, the data must be transferred to the controller, so that it can be further processed and written to the database
public function sort(){
$i = 1;
foreach ($_GET['sortblock'] as $id) {
//dd($id);
Model::where('id', $id)->update(['sort'=> $i]);
$i++;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question