Browse Source

added array model to dbo conversion method

tags/0.1.0
Robin Thoni 9 years ago
parent
commit
a050960104
1 changed files with 16 additions and 5 deletions
  1. 16
    5
      src/Utils/LuDataAccess.php

+ 16
- 5
src/Utils/LuDataAccess.php View File

26
         return $this->model;
26
         return $this->model;
27
     }
27
     }
28
 
28
 
29
+    /**
30
+     * @param $data LuModel[]
31
+     * @return LuDbo[]
32
+     */
33
+    protected function arrayToDbo($data)
34
+    {
35
+        $tab = [];
36
+        foreach ($data as $q) {
37
+            if (!is_null($q)) {
38
+                $tab[] = $q->toDbo();
39
+            }
40
+        }
41
+        return $tab;
42
+    }
43
+
29
     /**
44
     /**
30
      * @param $page int
45
      * @param $page int
31
      * @param $perPage int
46
      * @param $perPage int
43
 
58
 
44
         $data = $data->orderBy($column, $order)->take($perPage)->offset($page * $perPage)->get();
59
         $data = $data->orderBy($column, $order)->take($perPage)->offset($page * $perPage)->get();
45
 
60
 
46
-        $tab = [];
47
-        /* @var $data LuModel[] */
48
-        foreach ($data as $q) {
49
-            $tab[] = $q->toDbo();
50
-        }
61
+        $tab = $this->arrayToDbo($data);
51
         return $tab;
62
         return $tab;
52
     }
63
     }
53
 
64
 

Loading…
Cancel
Save