Kaynağa Gözat

fixed static changes

tags/0.1.0
Robin Thoni 8 yıl önce
ebeveyn
işleme
b80b0d1bf4
2 değiştirilmiş dosya ile 38 ekleme ve 13 silme
  1. 4
    4
      src/Utils/LuBusiness.php
  2. 34
    9
      src/Utils/LuDataAccess.php

+ 4
- 4
src/Utils/LuBusiness.php Dosyayı Görüntüle

111
     {
111
     {
112
         $class = get_called_class();
112
         $class = get_called_class();
113
         $me = new $class();
113
         $me = new $class();
114
-        return call_user_func_array(array($me, $name), $arguments);
114
+        return call_user_func_array(array($me, '_' . $name), $arguments);
115
     }
115
     }
116
 
116
 
117
     /**
117
     /**
122
      * @param $query string
122
      * @param $query string
123
      * @return LuDbo[]
123
      * @return LuDbo[]
124
      */
124
      */
125
-    public function search($page, $perPage, $column, $order, $query = null)
125
+    public function _search($page, $perPage, $column, $order, $query = null)
126
     {
126
     {
127
         return $this->dataAccess->search($page, $perPage, $column, $order, $query);
127
         return $this->dataAccess->search($page, $perPage, $column, $order, $query);
128
     }
128
     }
131
      * @param $id int
131
      * @param $id int
132
      * @return LuDbo|null
132
      * @return LuDbo|null
133
      */
133
      */
134
-    public function getById($id)
134
+    public function _getById($id)
135
     {
135
     {
136
         $data = $this->dataAccess->getById($id);
136
         $data = $this->dataAccess->getById($id);
137
         if (is_null($data))
137
         if (is_null($data))
142
     /**
142
     /**
143
      * @param $id int
143
      * @param $id int
144
      */
144
      */
145
-    public function deleteById($id)
145
+    public function _deleteById($id)
146
     {
146
     {
147
         $this->dataAccess->deleteById($id);
147
         $this->dataAccess->deleteById($id);
148
     }
148
     }

+ 34
- 9
src/Utils/LuDataAccess.php Dosyayı Görüntüle

12
     {
12
     {
13
         $class = get_called_class();
13
         $class = get_called_class();
14
         $me = new $class();
14
         $me = new $class();
15
-        return call_user_func_array(array($me, $name), $arguments);
15
+        return call_user_func_array(array($me, '_' . $name), $arguments);
16
     }
16
     }
17
 
17
 
18
     /**
18
     /**
73
      * @param $id int
73
      * @param $id int
74
      * @return LuModel
74
      * @return LuModel
75
      */
75
      */
76
-    protected function getModelById($id)
76
+    protected function _getModelById($id)
77
     {
77
     {
78
         return $this->model->where('id', '=', $id)->first();
78
         return $this->model->where('id', '=', $id)->first();
79
     }
79
     }
82
      * @param $id int
82
      * @param $id int
83
      * @return LuDbo|null
83
      * @return LuDbo|null
84
      */
84
      */
85
-    public function getById($id)
85
+    public function _getById($id)
86
     {
86
     {
87
-        $data = $this->getModelById($id);
87
+        $data = $this->_getModelById($id);
88
         if (is_null($data))
88
         if (is_null($data))
89
             return null;
89
             return null;
90
         return $data->toDbo();
90
         return $data->toDbo();
95
      */
95
      */
96
     public function deleteById($id)
96
     public function deleteById($id)
97
     {
97
     {
98
-        $data = $this->getModelById($id);
98
+        $data = $this->_getModelById($id);
99
         if (is_null($data))
99
         if (is_null($data))
100
             return;
100
             return;
101
         $data->delete();
101
         $data->delete();
105
      * @param $data LuDbo
105
      * @param $data LuDbo
106
      * @return int
106
      * @return int
107
      */
107
      */
108
-    public function addId($data)
108
+    public function _addId($data)
109
     {
109
     {
110
         $data = $this->model->fromDBO($data);
110
         $data = $this->model->fromDBO($data);
111
         $data->save();
111
         $data->save();
115
     /**
115
     /**
116
      * @param $data LuDbo
116
      * @param $data LuDbo
117
      */
117
      */
118
-    public function add($data)
118
+    public function _add($data)
119
     {
119
     {
120
         $data = $this->model->fromDBO($data);
120
         $data = $this->model->fromDBO($data);
121
         $data->save();
121
         $data->save();
126
      * @param $data LuDbo
126
      * @param $data LuDbo
127
      * @return LuDbo|null
127
      * @return LuDbo|null
128
      */
128
      */
129
-    public function editById($id, $data)
129
+    public function _editById($id, $data)
130
     {
130
     {
131
-        return $this->model->fromDBO($data, $this->getModelById($id))->save();
131
+        return $this->model->fromDBO($data, $this->_getModelById($id))->save();
132
+    }
133
+
134
+    /**
135
+     * @param $predicates array
136
+     * @param $orders array
137
+     * @param int $page
138
+     * @param int $perPage
139
+     * @return array
140
+     */
141
+    public function _getMultiple($predicates, $orders, $page = 0, $perPage = PHP_INT_MAX)
142
+    {
143
+        $model = $this->model;
144
+        foreach($predicates as $predicate)
145
+        {
146
+            $model = $model->where($predicate[0], $predicate[1], $predicate[2]);
147
+        }
148
+        $count = $model->count();
149
+        foreach($orders as $order)
150
+        {
151
+            $model = $model->orderBy($order[0], $order[1]);
152
+        }
153
+        $data = $model->take($perPage)->offset($page * $perPage)->get();
154
+        $dbo = self::arrayToDbo($data);
155
+
156
+        return array("Count" => $count, "Data" => $dbo);
132
     }
157
     }
133
 }
158
 }

Loading…
İptal
Kaydet