Completed
Push — master ( 0cc53e...46434a )
by Scott
03:56
created
models/Discount.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     /**
44 44
      * @var array Guarded fields
45 45
      */
46
-    protected $guarded = ['*'];
46
+    protected $guarded = [ '*' ];
47 47
 
48 48
     /**
49 49
      * @var array Fillable fields
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
     public function filterFields($fields)
157 157
     {
158 158
         $fields->amount_exact->hidden = $this->is_percentage;
159
-        $fields->amount_percentage->hidden = ! $this->is_percentage;
159
+        $fields->amount_percentage->hidden = !$this->is_percentage;
160 160
     }
161 161
 
162 162
     /**
@@ -168,14 +168,14 @@  discard block
 block discarded – undo
168 168
     {
169 169
         $productIds = $this->products()->lists('id');
170 170
         $categories = $this->categories()
171
-            ->with(['products' => function($product) {
171
+            ->with([ 'products' => function($product) {
172 172
                 return $product->select('id');
173
-            }])
174
-            ->get(['id']);
173
+            } ])
174
+            ->get([ 'id' ]);
175 175
 
176 176
         foreach ($categories as $category) {
177 177
             foreach ($category->products as $product) {
178
-                $productIds[] = $product->id;
178
+                $productIds[ ] = $product->id;
179 179
             }
180 180
         }
181 181
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
      */
190 190
     public function getAmountExactAttribute()
191 191
     {
192
-        return ! $this->is_percentage ? $this->amount : 0;
192
+        return !$this->is_percentage ? $this->amount : 0;
193 193
     }
194 194
 
195 195
     /**
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
     public function savePrices()
211 211
     {
212 212
         $id = $this->id;
213
-        Queue::push(function ($job) use ($id) {
213
+        Queue::push(function($job) use ($id) {
214 214
             $discount = Discount::findOrFail($id);
215 215
             $productIds = $discount->getAllProductIds();
216 216
             $products = Product::whereIn('id', $productIds)->select('id', 'base_price')->get();
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
      */
241 241
     public static function syncAllPrices()
242 242
     {
243
-        $data = [];
243
+        $data = [ ];
244 244
         $discounts = self::isNotExpired()->with('categories.products', 'products')->get();
245 245
         foreach ($discounts as $discount) {
246 246
             $products = $discount->products;
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
             }
250 250
 
251 251
             foreach ($products as $product) {
252
-                $data[] = [
252
+                $data[ ] = [
253 253
                     'discount_id' => $discount->id,
254 254
                     'end_at' => $discount->end_at,
255 255
                     'price' => $discount->calculatePrice($product->base_price),
@@ -266,17 +266,17 @@  discard block
 block discarded – undo
266 266
     public static function syncProductPrice(Product $product, array $categoryIds)
267 267
     {
268 268
         $discounts = self::isNotExpired()
269
-            ->whereHas('products', function ($query) use ($product) {
269
+            ->whereHas('products', function($query) use ($product) {
270 270
                 return $query->where('id', $product->id);
271 271
             })
272
-            ->orWhereHas('categories', function ($query) use ($categoryIds) {
272
+            ->orWhereHas('categories', function($query) use ($categoryIds) {
273 273
                 return $query->whereIn('id', $categoryIds);
274 274
             })
275 275
             ->get();
276 276
 
277
-        $data = [];
277
+        $data = [ ];
278 278
         foreach ($discounts as $discount) {
279
-            $data[] = [
279
+            $data[ ] = [
280 280
                 'discount_id' => $discount->id,
281 281
                 'end_at' => $discount->end_at,
282 282
                 'price' => $discount->calculatePrice($product->base_price),
Please login to merge, or discard this patch.