src/Engine/Traits/FromModelTraitPart/OrderTrait.php
public function reorder(array $newOrder)
    {
        $param = $this->crudeSetup->getOrderParameters();
        $idAttr = $param['idAttr'];
        $orderAttr = $param['orderAttr'];
        $table = $this->model->getTable();

        $data = collect($newOrder)->map(function($item) {
            return "({$item['id']},{$item['order']})";
        })->toArray();

        $data = implode(',', $data);

        \DB::statement("INSERT INTO {$table} (`{$idAttr}`,`{$orderAttr}`) VALUES {$data} ON DUPLICATE KEY UPDATE `{$orderAttr}`=VALUES(`{$orderAttr}`);");
    }
public function reorder(array $newOrder)
    {
        $param = $this->crudeSetup->getOrderParameters();
        $idAttr = $param['idAttr'];
        $orderAttr = $param['orderAttr'];
        $table = $this->model->getTable();

        $data = collect($newOrder)->map(function($item) {
            return "({$item['id']},{$item['order']})";
        })->toArray();

        $data = implode(',', $data);

        \DB::statement("INSERT INTO {$table} (`{$idAttr}`,`{$orderAttr}`) VALUES {$data} ON DUPLICATE KEY UPDATE `{$orderAttr}`=VALUES(`{$orderAttr}`);");
    }
public function reorder ( array $ newOrder ) { $ param = $ this -> crudeSetup -> getOrderParameters ( ) ; $ idAttr = $ param [ 'idAttr' ] ; $ orderAttr = $ param [ 'orderAttr' ] ; $ table = $ this -> model -> getTable ( ) ; $ data = collect ( $ newOrder ) -> map ( function ( $ item ) { return "({$item['id']},{$item['order']})" ; } ) -> toArray ( ) ; $ data = implode ( ',' , $ data ) ; \ DB :: statement ( "INSERT INTO {$table} (`{$idAttr}`,`{$orderAttr}`) VALUES {$data} ON DUPLICATE KEY UPDATE `{$orderAttr}`=VALUES(`{$orderAttr}`);" ) ; }
Set new order for selected items

@param  array $newOrder - list of ids and new order positions
Set new order for selected items