From c4201b2cc397a78a75f9c67e1d2fedbedeb11a0a Mon Sep 17 00:00:00 2001 From: Beppe Date: Thu, 1 Sep 2022 12:51:31 +0200 Subject: [PATCH] Fix generatore numerazione progressiva --- src/Util/Generator.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Util/Generator.php b/src/Util/Generator.php index a968f335c..3d18f9ff5 100755 --- a/src/Util/Generator.php +++ b/src/Util/Generator.php @@ -201,7 +201,11 @@ class Generator $maschera = Generator::complete($maschera, [], $date); $maschera = str_replace('#', '%', $maschera); - $query = Manager::table($table)->select($field)->where($field, 'like', $maschera)->orderByRaw($order); + //Lunghezza maschera + $mask_length = strlen($maschera); + + $query = Manager::table($table)->select($field)->where($field, 'like', $maschera)->whereRaw('LENGTH( numero_esterno )<='.$mask_length)->orderByRaw('LENGTH(numero_esterno) DESC')->orderByRaw($order); + foreach ($where as $and) { $query->whereRaw($and);