$ids = [4,3,1,2];
$result = DB::table('products')->where('status',1)->whereIn('id',$ids)->paginate(10);
So here the order of ids [4,3,1,2] in this same order i want paginate data
$ids = [4,3,1,2];
$result = DB::table('products')->where('status',1)->whereIn('id',$ids)->paginate(10);
So here the order of ids [4,3,1,2] in this same order i want paginate data
Finally i got answer.
$ids = [4,3,1,2];
$ids_ordered = implode(',', $ids);
$result = DB::table('products')->where('status',1)->whereIn('id',$ids)->orderByRaw(DB::raw("FIELD(id, $ids_ordered)"))->paginate(10);