Passed
Push — master ( 057032...a20925 )
by Matthijs
02:37 queued 44s
created
src/Services/Product/Entity/ProductRepository.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
    
27 27
     public function selectByLimitAndOrderBy($shopId, $limit, $orderBy)
28 28
     {
29
-        return $this->model->with(array('productCategory', 'relatedProducts', 'productImages' => function ($query) {
29
+        return $this->model->with(array('productCategory', 'relatedProducts', 'productImages' => function($query) {
30 30
             $query->orderBy('rank', 'asc');
31 31
         }))->where('shop_id', '=', $shopId)->where('active', '=', 1)->limit($limit)->orderBy('id', $orderBy)->get();
32 32
     }
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     
39 39
     public function selectAllExport()
40 40
     {
41
-        return $this->model->with(array('productImages' => function ($query) {
41
+        return $this->model->with(array('productImages' => function($query) {
42 42
             $query->orderBy('rank', 'asc');
43 43
         }))->where('active', '=', 1)->where('shop_id', '=', auth('hideyobackend')->user()->selected_shop_id)->get();
44 44
     }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
     public function selectOneById($productId)
74 74
     {
75
-        $result = $this->model->with(array('productCategory', 'relatedProducts', 'productImages' => function ($query) {
75
+        $result = $this->model->with(array('productCategory', 'relatedProducts', 'productImages' => function($query) {
76 76
             $query->orderBy('rank', 'asc');
77 77
         }))->where('active', '=', 1)->where('id', '=', $productId)->get()->first();
78 78
         return $result;
@@ -93,19 +93,19 @@  discard block
 block discarded – undo
93 93
     function selectAllByShopIdAndProductCategoryId($shopId, $productCategoryId, $filters = false)
94 94
     {
95 95
         $result = $this->model
96
-        ->with(array('subcategories', 'extraFields' => function ($query) {
96
+        ->with(array('subcategories', 'extraFields' => function($query) {
97 97
             $query->with('extraField')->orderBy('id', 'desc');
98
-        }, 'taxRate', 'productCategory',  'relatedProducts' => function ($query) {
98
+        }, 'taxRate', 'productCategory', 'relatedProducts' => function($query) {
99 99
             $query->with('productImages')->orderBy('rank', 'asc');
100
-        }, 'productImages' => function ($query) {
100
+        }, 'productImages' => function($query) {
101 101
             $query->orderBy('rank', 'asc');
102 102
         }))
103 103
         ->where('shop_id', '=', $shopId)
104 104
         ->where('active', '=', 1)
105 105
                 ->whereNotNull('product.product_category_id')
106
-        ->where(function ($query) use ($productCategoryId) {
106
+        ->where(function($query) use ($productCategoryId) {
107 107
             $query->where('product_category_id', '=', $productCategoryId);
108
-            $query->orWhereHas('subcategories', function ($query) use ($productCategoryId) {
108
+            $query->orWhereHas('subcategories', function($query) use ($productCategoryId) {
109 109
                 $query->where('product_category_id', '=', $productCategoryId);
110 110
             });
111 111
         });
@@ -120,14 +120,14 @@  discard block
 block discarded – undo
120 120
            return $this->model->with(
121 121
                array(
122 122
                 'attributeGroup',
123
-                'attributes' => function ($query) {
123
+                'attributes' => function($query) {
124 124
                     $query->with(
125 125
                         array(
126
-                            'combinations' => function ($query) {
126
+                            'combinations' => function($query) {
127 127
                                 $query->with(
128 128
                                     array(
129 129
                                         'productAttribute',
130
-                                        'attribute' => function ($query) {
130
+                                        'attribute' => function($query) {
131 131
                                             $query->with(
132 132
                                                 array(
133 133
                                                     'attributeGroup'
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
                             )
141 141
                     )->orderBy('default_on', 'desc');
142 142
                 },
143
-                'extraFields' => function ($query) {
143
+                'extraFields' => function($query) {
144 144
                     $query->where(
145 145
                         'value',
146 146
                         '!=',
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
                         'desc'
152 152
                     );
153 153
                 },
154
-                'relatedProducts' => function ($query) {
154
+                'relatedProducts' => function($query) {
155 155
                     $query->with(
156 156
                         'productImages',
157 157
                         'productCategory'
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                         'asc'
161 161
                     );
162 162
                 },
163
-                'productImages' => function ($query) {
163
+                'productImages' => function($query) {
164 164
                     $query->orderBy(
165 165
                         'rank',
166 166
                         'asc'
@@ -174,31 +174,31 @@  discard block
 block discarded – undo
174 174
     {
175 175
         $images = array();
176 176
 
177
-        if($product->productImages->count()) {  
177
+        if ($product->productImages->count()) {  
178 178
 
179 179
             $images = $product->productImages()->has('relatedAttributes', '=', 0)->has('relatedProductAttributes', '=', 0)->orderBy('rank', '=', 'asc')->get();
180 180
 
181
-            if($combinationsIds) {
181
+            if ($combinationsIds) {
182 182
 
183 183
                 $imagesRelatedAttributes = ProductImage::
184 184
                 whereHas('relatedAttributes', function($query) use ($combinationsIds, $product) { $query->with(array('productImage'))->whereIn('attribute_id', $combinationsIds); })
185 185
                 ->where('product_id', '=', $product->id)
186 186
                 ->get();
187 187
 
188
-                if($imagesRelatedAttributes) {
188
+                if ($imagesRelatedAttributes) {
189 189
                     $images = $images->merge($imagesRelatedAttributes)->sortBy('rank');
190 190
                 }
191 191
                 
192 192
             }
193 193
 
194
-            if($productAttributeId) {
194
+            if ($productAttributeId) {
195 195
 
196 196
                 $imagesRelatedProductAttributes = ProductImage::
197 197
                 whereHas('relatedProductAttributes', function($query) use ($productAttributeId, $product) { $query->where('product_attribute_id', '=', $productAttributeId); })
198 198
                 ->where('product_id', '=', $product->id)
199 199
                 ->get();
200 200
 
201
-                if($imagesRelatedProductAttributes) {
201
+                if ($imagesRelatedProductAttributes) {
202 202
                     $images = $images->merge($imagesRelatedProductAttributes)->sortBy('rank');
203 203
                 }   
204 204
 
Please login to merge, or discard this patch.