$query = "INSERT INTO table_name (" . implode(',', $columns) . ") VALUES " 
. implode(
    ',',
    array_map(function($data) {
        return "(" . implode(",", array_fill(0, count($data) , '?')) . ")";
    }, $datas)
)
. " ON DUPLICATE KEY UPDATE "
. implode(
    ',',
    array_map(function($column) {
        return $column . "=VALUES(" . $column . ')';
    }, $columns)
);
DB::statement($query, array_collapse($datas));
          Last active
          October 7, 2018 10:22 
        
      - 
      
 - 
        
Save yassine-khachlek/de9d2a0ba25becb06972ff24c1dfa656 to your computer and use it in GitHub Desktop.  
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment